{"id":22253398,"url":"https://github.com/mary-ext/pkg-keybinds","last_synced_at":"2025-08-04T16:35:39.418Z","repository":{"id":265429132,"uuid":"862093841","full_name":"mary-ext/pkg-keybinds","owner":"mary-ext","description":"Lightweight and \"sensible\" keyboard handler","archived":false,"fork":false,"pushed_at":"2024-09-24T19:22:14.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2025-03-19T21:28:35.436Z","etag":null,"topics":["typescript","web"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mary-ext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mary-ext","ko_fi":"maryext"}},"created_at":"2024-09-24T03:02:15.000Z","updated_at":"2025-01-03T12:58:13.000Z","dependencies_parsed_at":"2024-11-29T10:57:36.478Z","dependency_job_id":"6d5d5006-b718-4df3-a848-b0c9cf60b619","html_url":"https://github.com/mary-ext/pkg-keybinds","commit_stats":null,"previous_names":["mary-ext/pkg-keybinds"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mary-ext%2Fpkg-keybinds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mary-ext%2Fpkg-keybinds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mary-ext%2Fpkg-keybinds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mary-ext%2Fpkg-keybinds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mary-ext","download_url":"https://codeload.github.com/mary-ext/pkg-keybinds/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245460149,"owners_count":20619015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["typescript","web"],"created_at":"2024-12-03T07:18:08.919Z","updated_at":"2025-03-25T12:25:03.391Z","avatar_url":"https://github.com/mary-ext.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mary-ext","https://ko-fi.com/maryext"],"categories":[],"sub_categories":[],"readme":"# @externdefs/keybinds\n\nLibrary for handling keyboard shortcuts (keybinds).\n\n- **Sensible**, tries to achieve a default that makes \"sense\"  \n  Keybinds can't interfere with common user expectations\n- **Lightweight**, much smaller than `hotkeys-js` library.\n\nUse this [web page](https://mary.my.id/tools/keydown-visualizer) to get the\nright keybinds for use here.\n\n```ts\nconst handler = createKeybindHandler({\n\t'$mod+K'() {\n\t\t// Open search modal...\n\t},\n\n\ts() {\n\t\t// Save...\n\t},\n});\n\nwindow.addEventListener('keydown', handler);\n```\n\n## \"Sensible\" keyboard handling\n\nThe library reserves certain keybinds for the following scenarios:\n\n- `\u003cinput type=text\u003e`, `\u003ctextarea\u003e` and `\u003cdiv contenteditable\u003e`\n  - Text insertion (`a`, `s`, ...)\n  - Uppercase text insertion (`Shift+A`, `Shift+S`, ...)\n  - Text deletion (`Backspace`, `$mod+Backspace`)\n  - Cursor per-char positioning (`ArrowLeft`, `ArrowRight`, ...)\n  - Cursor per-char selection (`Shift+ArrowLeft`, `Shift+ArrowRight`, ...)\n  - Cursor per-word positioning (`$mod+ArrowLeft`, `$mod+ArrowRight`, ...)\n  - Cursor per-word selection (`$mod+Shift+ArrowLeft`, `$mod+Shift+ArrowRight`, ...)\n  - Common text manipulation shortcuts (`$mod+a`, `$mod+v`, ...)\n  - Multiline only: New line insertion (`Enter`)\n  - Date/time inputs only: Open picker UI (`Enter`)\n- `\u003cinput type=checkbox\u003e`\n  - Tick/unticking check (`Space`)\n- `\u003cinput type=radio\u003e` and `\u003cinput type=range\u003e`\n  - Selection (`ArrowLeft`, `ArrowRight`)\n- `\u003cbutton\u003e` and `\u003cinput type=file\u003e`\n  - Action trigger (`Space`, `Enter`)\n- `\u003ca href\u003e`\n  - Link navigation (`Enter`, `$mod+Enter`, ...)\n- `\u003cselect\u003e`\n  - Jump to value (`a`, `s`, ...)\n\n`createKeybindHandler` will also call `.preventDefault()` on matching events by\ndefault, you can disable this by passing `false` as the second parameter. It's\nrecommended to just write your own handler however if you need flexibility, all\nthe relevant functions are exported.\n\n## License\n\nBSD-3-Clause © Mary\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmary-ext%2Fpkg-keybinds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmary-ext%2Fpkg-keybinds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmary-ext%2Fpkg-keybinds/lists"}