{"id":13727096,"url":"https://github.com/kripod/keez","last_synced_at":"2025-04-16T18:48:55.456Z","repository":{"id":57288939,"uuid":"320869430","full_name":"kripod/keez","owner":"kripod","description":"Frictionless hotkey handling for browsers","archived":false,"fork":false,"pushed_at":"2020-12-12T16:56:58.000Z","size":24,"stargazers_count":55,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-02T05:05:07.874Z","etag":null,"topics":["event","handler","hotkey","keyboard","shortcut"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/keez","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kripod.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}},"created_at":"2020-12-12T16:06:48.000Z","updated_at":"2021-12-30T22:39:45.000Z","dependencies_parsed_at":"2022-09-17T00:50:22.368Z","dependency_job_id":null,"html_url":"https://github.com/kripod/keez","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fkeez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fkeez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fkeez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kripod%2Fkeez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kripod","download_url":"https://codeload.github.com/kripod/keez/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249266475,"owners_count":21240762,"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":["event","handler","hotkey","keyboard","shortcut"],"created_at":"2024-08-03T01:03:39.321Z","updated_at":"2025-04-16T18:48:55.415Z","avatar_url":"https://github.com/kripod.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# keez\n\nFrictionless hotkey handling for browsers\n\n[![npm](https://img.shields.io/npm/v/keez)](https://www.npmjs.com/package/keez)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/keez)](https://bundlephobia.com/result?p=keez)\n\n## Usage\n\n```js\nimport { captureKeys } from \"keez\";\n\nconst saveCommand = captureKeys(\"CmdOrCtrl\", \"S\");\nconst italicCommand = captureKeys(\"CmdOrCtrl\", \"I\");\n\ndocument.addEventListener(\"keydown\", (event) =\u003e {\n  if (saveCommand(event)) {\n    /* Do something, e.g. call `fetch` */\n  } else if (italicCommand(event)) {\n    /* Do something else, e.g. format selected text */\n  }\n});\n```\n\n## Features\n\n- `CmdOrCtrl` modifier for interoperability between operating systems\n- Supports synthetic events (e.g. for [React](https://reactjs.org/) elements)\n- Calls `event.preventDefault()` when a match is found, suppressing handlers of the underlying browser (or even the system)\n- TypeScript-based code completion for common modifier keys\n- Low overhead, compared to similar libraries\n\n## Browser support\n\n[Every browser with the `Set` built-in](https://caniuse.com/mdn-javascript_builtins_set) is supported out of the box.\n\n## Implementation details\n\nThere are quite a few attributes to handle keystrokes with:\n\n|                                          | Layout-aware | Modifier-independent | Supports all events | Named non-printables |\n| ---------------------------------------- | :----------: | :------------------: | :-----------------: | :------------------: |\n| `key`                                    |      ✓       |          ✗           |          ✓          |        **✓**         |\n| `code`                                   |      ✗       |          ✓           |          ✓          |          ✓           |\n| `keyCode`\u0026nbsp;/\u0026nbsp;`which` _(legacy)_ |    **✓**     |        **✓**         |        **✓**        |          ✗           |\n| `charCode` _(legacy)_                    |      ✓       |          ✓           |          ✗          |          ✗           |\n\nDespite being a legacy attribute, `keyCode` is used in comparisons by default. It’s independent from modifiers, unlike the modern `key` alternative.\n\nHowever, when it comes to [named key attribute values](https://www.w3.org/TR/uievents-key/#named-key-attribute-values) (e.g. `Escape` or `Backspace`), the `key` property is used under the hood.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripod%2Fkeez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkripod%2Fkeez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkripod%2Fkeez/lists"}