{"name":"hotkeys-js","version":"4.0.0","keywords":["hotkey","hotkeys","hotkeys-js","hotkeysjs","key","keys","keyboard","shortcuts","keypress"],"author":{"name":"kenny wong","email":"wowohoo@qq.com"},"license":"MIT","_id":"hotkeys-js@4.0.0","maintainers":[{"name":"wcjiang","email":"398188662@qq.com"}],"homepage":"https://jaywcjlove.github.io/hotkeys-js","bugs":{"url":"https://github.com/jaywcjlove/hotkeys-js/issues"},"dist":{"shasum":"75336c0ac610ad384d286c61c519909dcd4bdf6b","tarball":"http://registry-npm.ywwl.com/hotkeys-js/download/hotkeys-js-4.0.0.tgz","fileCount":24,"integrity":"sha512-gIoeqMWYqPIItc4HaseVbtTRpEpBbeufZMUcoWtN62JZdDq3KadS1ijN6wpaDjTzRK7PjT3QOPUcx+yNT0rrZQ==","signatures":[{"sig":"MEUCIDdPuz2bApLKm8eG+XfygzcacSWfN2RstUNdsNGm2TB5AiEA2v1Rq8wYpKNxAxUyGTRwPDZ10quSXCgoMu4Wda4qLwI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/hotkeys-js@4.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":4375965,"size":2569671,"noattachment":false,"key":"/hotkeys-js/-/hotkeys-js-4.0.0.tgz"},"main":"dist/hotkeys-js.umd.cjs","type":"module","types":"dist/index.d.ts","module":"dist/hotkeys-js.js","browser":"dist/hotkeys-js.min.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/hotkeys-js.js","browser":"./dist/hotkeys-js.min.js","require":"./dist/hotkeys-js.umd.cjs"}},"funding":"https://jaywcjlove.github.io/#/sponsor","gitHead":"fb38730b52ebbe8dc5e5e8ec15f6c417e8ce434d","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:063fe66e-7668-40b2-921b-d3136b17eaa7"}},"overrides":{"react":"^19.2.0","react-dom":"^19.2.0"},"repository":{"url":"git+https://github.com/jaywcjlove/hotkeys-js.git","type":"git"},"_npmVersion":"11.6.2","description":"A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/hotkeys-js_4.0.0_1766424953358_0.2697450724048469","host":"s3://npm-registry-packages-npm-production"},"readme":"<div markdown=\"1\">\n  <sup>Using <a href=\"https://wangchujiang.com/#/app\" target=\"_blank\">my app</a> is also a way to <a href=\"https://wangchujiang.com/#/sponsor\" target=\"_blank\">support</a> me:</sup>\n  <br>\n  <a target=\"_blank\" href=\"https://wangchujiang.com/dock-lift/\" title=\"DockLift: Windows, Here\"><img alt=\"DockLift: Windows, Here\" height=\"52\" src=\"https://wangchujiang.com/appicon/dock-lift.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6766860898\" title=\"Zipora: Zip/RAR/7Z Unarchiver\"><img alt=\"Zipora: Zip/RAR/7Z Unarchiver\" height=\"52\" src=\"https://wangchujiang.com/appicon/zipora.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6758053530\" title=\"Scap: Screenshot & Markup Edit for macOS\"><img alt=\"Scap: Screenshot & Markup Edit\" height=\"52\" src=\"https://wangchujiang.com/appicon/scap.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6757317079\" title=\"Screen Test for macOS\"><img alt=\"Screen Test\" height=\"52\" src=\"https://wangchujiang.com/appicon/screen-test.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6755948110\" title=\"Deskmark for macOS\"><img alt=\"Deskmark\" height=\"52\" src=\"https://wangchujiang.com/appicon/deskmark.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6500434773\" title=\"Keyzer for macOS\"><img alt=\"Keyzer\" height=\"52\" src=\"https://wangchujiang.com/appicon/keyzer.png\"></a>\n  <a target=\"_blank\" href=\"https://github.com/jaywcjlove/vidwall-hub\" title=\"Vidwall Hub for macOS\"><img alt=\"Vidwall Hub\" height=\"52\" src=\"https://wangchujiang.com/appicon/vidwall-hub.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6752624705\" title=\"VidCrop for macOS\"><img alt=\"VidCrop\" height=\"52\" src=\"https://wangchujiang.com/appicon/vidcrop.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6747587746\" title=\"Vidwall for macOS\"><img alt=\"Vidwall\" height=\"52\" src=\"https://wangchujiang.com/appicon/vidwall.png\"></a>\n  <a target=\"_blank\" href=\"https://wangchujiang.com/mousio-hint/\" title=\"Mousio Hint for macOS\"><img alt=\"Mousio Hint\" height=\"52\" src=\"https://wangchujiang.com/appicon/mousio-hint.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6746747327\" title=\"Mousio for macOS\"><img alt=\"Mousio\" height=\"52\" src=\"https://wangchujiang.com/appicon/mousio.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6745227444\" title=\"Musicer for macOS\"><img alt=\"Musicer\" height=\"52\" src=\"https://wangchujiang.com/appicon/musicer.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6743841447\" title=\"Audioer for macOS\"><img alt=\"Audioer\" height=\"52\" src=\"https://wangchujiang.com/appicon/audioer.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6744690194\" title=\"FileSentinel for macOS\"><img alt=\"FileSentinel\" height=\"52\" src=\"https://wangchujiang.com/appicon/file-sentinel.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6743495172\" title=\"FocusCursor for macOS\"><img alt=\"FocusCursor\" height=\"52\" src=\"https://wangchujiang.com/appicon/focus-cursor.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6742680573\" title=\"Videoer for macOS\"><img alt=\"Videoer\" height=\"52\" src=\"https://wangchujiang.com/appicon/videoer.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6740425504\" title=\"KeyClicker for macOS\"><img alt=\"KeyClicker\" height=\"52\" src=\"https://wangchujiang.com/appicon/key-clicker.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6739052447\" title=\"DayBar for macOS\"><img alt=\"DayBar\" height=\"52\" src=\"https://wangchujiang.com/appicon/daybar.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6739444407\" title=\"Iconed for macOS\"><img alt=\"Iconed\" height=\"52\" src=\"https://wangchujiang.com/appicon/iconed.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6737160756\" title=\"Menuist for macOS\"><img alt=\"Menuist\" height=\"52\" src=\"https://wangchujiang.com/appicon/rightmenu-master.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6723903021\" title=\"Paste Quick for macOS\"><img alt=\"Quick RSS\" height=\"52\" src=\"https://wangchujiang.com/appicon/paste-quick.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6670696072&platform=mac\" title=\"Quick RSS for macOS/iOS\"><img alt=\"Quick RSS\" height=\"52\" src=\"https://wangchujiang.com/appicon/quick-rss.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6670167443\" title=\"Web Serve for macOS\"><img alt=\"Web Serve\" height=\"52\" src=\"https://wangchujiang.com/appicon/web-serve.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6503953628&platform=mac\" title=\"Copybook Generator for macOS/iOS\"><img alt=\"Copybook Generator\" height=\"52\" src=\"https://wangchujiang.com/appicon/copybook-generator.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6471227008&platform=mac\" title=\"DevTutor for macOS/iOS\"><img alt=\"DevTutor for SwiftUI\" height=\"52\" src=\"https://wangchujiang.com/appicon/devtutor.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6479819388&platform=mac\" title=\"RegexMate for macOS/iOS\"><img alt=\"RegexMate\" height=\"52\" src=\"https://wangchujiang.com/appicon/regex-mate.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6479194014&platform=mac\" title=\"Time Passage for macOS/iOS\"><img alt=\"Time Passage\" height=\"52\" src=\"https://wangchujiang.com/appicon/time-passage.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6478772538\" title=\"IconizeFolder for macOS\"><img alt=\"Iconize Folder\" height=\"52\" src=\"https://wangchujiang.com/appicon/iconize-folder.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6478511402&platform=mac\" title=\"Textsound Saver for macOS/iOS\"><img alt=\"Textsound Saver\" height=\"52\" src=\"https://wangchujiang.com/appicon/textsound-saver.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6476924627\" title=\"Create Custom Symbols for macOS\"><img alt=\"Create Custom Symbols\" height=\"52\" src=\"https://wangchujiang.com/appicon/create-custom-symbols.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6476452351\" title=\"DevHub for macOS\"><img alt=\"DevHub\" height=\"52\" src=\"https://wangchujiang.com/appicon/devhub.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6476400184\" title=\"Resume Revise for macOS\"><img alt=\"Resume Revise\" height=\"52\" src=\"https://wangchujiang.com/appicon/resume-revise.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6472593276\" title=\"Palette Genius for macOS\"><img alt=\"Palette Genius\" height=\"52\" src=\"https://wangchujiang.com/appicon/palette-genius.png\"></a>\n  <a target=\"_blank\" href=\"https://jaywcjlove.github.io/maslink/?id=6470879005\" title=\"Symbol Scribe for macOS\"><img alt=\"Symbol Scribe\" height=\"52\" src=\"https://wangchujiang.com/appicon/symbol-scribe.png\"></a>\n</div>\n<hr>\n\n# Hotkeys\n\n[![Buy me a coffee](https://img.shields.io/badge/Buy_Me_a_Coffee-ffdd00?logo=buy-me-a-coffee&logoColor=black)](https://jaywcjlove.github.io/#/sponsor)\n[![Follow On X](https://img.shields.io/badge/Follow%20on%20X-333333?logo=x&logoColor=white)](https://x.com/jaywcjlove)\n[![](https://img.shields.io/npm/dm/hotkeys-js?logo=npm&label=)](https://www.npmjs.com/package/hotkeys-js)\n[![](https://img.shields.io/github/stars/jaywcjlove/hotkeys-js.svg)](https://github.com/jaywcjlove/hotkeys/stargazers)\n[![GitHub Actions CI](https://github.com/jaywcjlove/hotkeys-js/actions/workflows/ci.yml/badge.svg)](https://github.com/jaywcjlove/hotkeys-js/actions/workflows/ci.yml)\n[![Coverage Status](https://jaywcjlove.github.io/hotkeys-js/coverage.svg)](https://jaywcjlove.github.io/hotkeys-js/lcov-report/index.html)\n[![Chinese](https://jaywcjlove.github.io/sb/lang/chinese.svg)](https://wangchujiang.com/hotkeys-js/?lang=zh)\n[![jaywcjlove/hotkeys-js](https://jaywcjlove.github.io/sb/ico/gitee.svg)](https://gitee.com/jaywcjlove/hotkeys)\n\nHotKeys.js is an input capture library with some very special features, it is easy to pick up and use, has a reasonable footprint ([~8kB](https://bundlephobia.com/result?p=hotkeys-js)) (gzipped: **`3.8kB`**), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks. Official document [demo preview](https://jaywcjlove.github.io/hotkeys-js), [compatibility test](https://jaywcjlove.github.io/hotkeys-js/dist/compatibility-test.html). [More examples](https://github.com/jaywcjlove/hotkeys-js/issues?q=label%3ADemo+).\n\n```bash\n╭┈┈╮          ╭┈┈╮  ╭┈┈╮\n┆  ├┈┈..┈┈┈┈┈.┆  └┈╮┆  ├┈┈..┈┈┈┈┈..┈┈.┈┈..┈┈┈┈┈.\n┆     ┆┆  □  ┆┆   ┈┤┆    < ┆  -__┘┆  ┆  ┆┆__ ┈┈┤\n╰┈┈┴┈┈╯╰┈┈┈┈┈╯╰┈┈┈┈╯╰┈┈┴┈┈╯╰┈┈┈┈┈╯╰┈┈┈  ┆╰┈┈┈┈┈╯\n                                  ╰┈┈┈┈┈╯\n```\n\n## Usage\n\nYou will need `Node.js` installed on your system.\n\n```bash\nnpm install hotkeys-js --save\n```\n\n```js\nimport hotkeys from 'hotkeys-js';\n\nhotkeys('f5', function(event, handler){\n  // Prevent the default refresh event under WINDOWS system\n  event.preventDefault()\n  alert('you pressed F5!')\n});\n```\n\n### Browser Usage\n\nOr manually download and link **hotkeys.js** in your HTML. The library provides different formats for different use cases:\n\n**CDN Links:** [UNPKG](https://unpkg.com/hotkeys-js/dist/) | [jsDelivr](https://cdn.jsdelivr.net/npm/hotkeys-js/) | [Githack](https://raw.githack.com/jaywcjlove/hotkeys/master/dist/) | [Statically](https://cdn.statically.io/gh/jaywcjlove/hotkeys/master/dist/)\n\n**Available Formats:**\n\n**IIFE (Immediately Invoked Function Expression) - Recommended for direct browser usage:**\n\n```html\n<script src=\"https://unpkg.com/hotkeys-js/dist/hotkeys-js.min.js\">\n</script>\n<script type=\"text/javascript\">\nhotkeys('ctrl+a,ctrl+b,r,f', function (event, handler){\n  switch (handler.key) {\n    case 'ctrl+a': alert('you pressed ctrl+a!');\n      break;\n    case 'ctrl+b': alert('you pressed ctrl+b!');\n      break;\n    case 'r': alert('you pressed r!');\n      break;\n    case 'f': alert('you pressed f!');\n      break;\n    default: alert(event);\n  }\n});\n</script>\n```\n\n**UMD (Universal Module Definition) - For CommonJS/AMD environments:**\n\n```html\n<script src=\"https://unpkg.com/hotkeys-js/dist/hotkeys-js.umd.cjs\">\n</script>\n```\n\n**ES Module - For modern browsers with module support:**\n\n```html\n<script type=\"module\">\nimport hotkeys from 'https://unpkg.com/hotkeys-js/dist/hotkeys-js.js';\nhotkeys('ctrl+a', function(event, handler){\n  alert('you pressed ctrl+a!');\n});\n</script>\n```\n\n### Used in React\n\n[react-hotkeys](https://github.com/jaywcjlove/react-hotkeys) is the React component that listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts. Detailed use method please see its documentation [react-hotkeys](https://github.com/jaywcjlove/react-hotkeys).\n\n[react-hotkeys-hook](https://github.com/JohannesKlauss/react-hotkeys-hook) - React hook for using keyboard shortcuts in components. Make sure that you have at least version 16.8 of react and react-dom installed, or otherwise hooks won't work for you.\n\n## Browser Support\n\nHotkeys.js has been tested and should work in.\n\n```shell\nInternet Explorer 6+\nSafari\nFirefox\nChrome\n```\n\n## Supported Keys\n\nHotKeys understands the following modifiers: `⇧`, `shift`, `option`, `⌥`, `alt`, `ctrl`, `control`, `command`, and `⌘`.\n\nThe following special keys can be used for shortcuts: backspace, tab, clear, enter, return, esc, escape, space, up, down, left, right, home, end, pageup, pagedown, del, delete, f1 through f19, num_0 through num_9, num_multiply, num_add, num_enter, num_subtract, num_decimal, num_divide.\n\n`⌘` Command()  \n`⌃` Control  \n`⌥` Option(alt)  \n`⇧` Shift  \n`⇪` Caps Lock(Capital)  \n~~`fn` Does not support fn~~  \n`↩︎` return/Enter space  \n\n## Defining Shortcuts\n\nOne global method is exposed, key which defines shortcuts when called directly.\n\n```ts\ndeclare interface HotkeysInterface extends HotkeysAPI {\n  (key: string, method: KeyHandler): void;\n  (key: string, scope: string, method: KeyHandler): void;\n  (key: string, option: HotkeysOptions, method: KeyHandler): void;\n  shift?: boolean;\n  ctrl?: boolean;\n  alt?: boolean;\n  option?: boolean;\n  control?: boolean;\n  cmd?: boolean;\n  command?: boolean;\n}\ndeclare interface HotkeysAPI {\n  setScope: SetScope;\n  getScope: GetScope;\n  deleteScope: DeleteScope;\n  getPressedKeyCodes: GetPressedKeyCodes;\n  getPressedKeyString: GetPressedKeyString;\n  getAllKeyCodes: GetAllKeyCodes;\n  isPressed: IsPressed;\n  filter: Filter;\n  trigger: Trigger;\n  unbind: Unbind;\n  noConflict: NoConflict;\n  keyMap: Record<string, number>;\n  modifier: Record<string, number>;\n  modifierMap: Record<string | number, number | string>;\n}\n```\n\n\n```js\nhotkeys('f5', function(event, handler) {\n  // Prevent the default refresh event under WINDOWS system\n  event.preventDefault();\n  alert('you pressed F5!');\n});\n\n// Returning false stops the event and prevents default browser events\n// Mac OS system defines `command + r` as a refresh shortcut\nhotkeys('ctrl+r, command+r', function() {\n  alert('stopped reload!');\n  return false;\n});\n\n// Single key\nhotkeys('a', function(event,handler){\n  //event.srcElement: input\n  //event.target: input\n  if(event.target === \"input\"){\n      alert('you pressed a!')\n  }\n  alert('you pressed a!')\n});\n\n// Key Combination\nhotkeys('ctrl+a,ctrl+b,r,f', function (event, handler){\n  switch (handler.key) {\n    case 'ctrl+a': alert('you pressed ctrl+a!');\n      break;\n    case 'ctrl+b': alert('you pressed ctrl+b!');\n      break;\n    case 'r': alert('you pressed r!');\n      break;\n    case 'f': alert('you pressed f!');\n      break;\n    default: alert(event);\n  }\n});\n\nhotkeys('ctrl+a+s', function() {\n    alert('you pressed ctrl+a+s!');\n});\n\n// Using a scope\nhotkeys('*','wcj', function(event){\n  console.log('do something', event);\n});\n```\n\n#### option\n\n- `scope<String>`: Sets the scope in which the shortcut key is active\n- `element<HTMLElement>`: Specifies the DOM element to bind the event to\n- `keyup<Boolean>`: Whether to trigger the shortcut on key release\n- `keydown<Boolean>`: Whether to trigger the shortcut on key press\n- `splitKey<String>`: Delimiter for key combinations (default is `+`)\n- `capture<Boolean>`: Whether to trigger the listener during the capture phase (before the event bubbles down)\n- `single<Boolean>`: Allows only one callback function (automatically unbinds previous one)\n\n```js\nhotkeys('o, enter', {\n  scope: 'wcj',\n  element: document.getElementById('wrapper'),\n}, function() {\n  console.log('do something else');\n});\n\nhotkeys('ctrl-+', { splitKey: '-' }, function(e) {\n  console.log('you pressed ctrl and +');\n});\n\nhotkeys('+', { splitKey: '-' }, function(e){\n  console.log('you pressed +');\n})\n```\n\n**keyup**\n\n**key down** and **key up** both perform callback events.\n\n```js\nhotkeys('ctrl+a,alt+a+s', {keyup: true}, function(event, handler) {\n  if (event.type === 'keydown') {\n    console.log('keydown:', event.type, handler, handler.key);\n  }\n\n  if (event.type === 'keyup') {\n    console.log('keyup:', event.type, handler, handler.key);\n  }\n});\n```\n\n## API REFERENCE\n\nAsterisk \"*\"\n\nModifier key judgments\n\n```js\nhotkeys('*', function() {\n  if (hotkeys.shift) {\n    console.log('shift is pressed!');\n  }\n\n  if (hotkeys.ctrl) {\n    console.log('ctrl is pressed!');\n  }\n\n  if (hotkeys.alt) {\n    console.log('alt is pressed!');\n  }\n\n  if (hotkeys.option) {\n    console.log('option is pressed!');\n  }\n\n  if (hotkeys.control) {\n    console.log('control is pressed!');\n  }\n\n  if (hotkeys.cmd) {\n    console.log('cmd is pressed!');\n  }\n\n  if (hotkeys.command) {\n    console.log('command is pressed!');\n  }\n});\n```\n\n### setScope\n\nUse the `hotkeys.setScope` method to set scope. There can only be one active scope besides 'all'.  By default 'all' is always active.\n\n```js\n// Define shortcuts with a scope\nhotkeys('ctrl+o, ctrl+alt+enter', 'issues', function() {\n  console.log('do something');\n});\nhotkeys('o, enter', 'files', function() {\n  console.log('do something else');\n});\n\n// Set the scope (only 'all' and 'issues' shortcuts will be honored)\nhotkeys.setScope('issues'); // default scope is 'all'\n```\n\n### getScope\n\nUse the `hotkeys.getScope` method to get scope.\n\n```js\nhotkeys.getScope();\n```\n\n### deleteScope\n\nUse the `hotkeys.deleteScope` method to delete a scope. This will also remove all associated hotkeys with it.\n\n```js\nhotkeys.deleteScope('issues');\n```\nYou can use second argument, if need set new scope after deleting.\n\n```js\nhotkeys.deleteScope('issues', 'newScopeName');\n```\n\n### unbind\n\nSimilar to defining shortcuts, they can be unbound using `hotkeys.unbind`.\n\n```js\n// unbind 'a' handler\nhotkeys.unbind('a');\n\n// Unbind a hotkeys only for a single scope\n// If no scope is specified it defaults to the current \n// scope (hotkeys.getScope())\nhotkeys.unbind('o, enter', 'issues');\nhotkeys.unbind('o, enter', 'files');\n```\n\nUnbind events through functions.\n\n```js\nfunction example() {\n  hotkeys('a', example);\n  hotkeys.unbind('a', example);\n\n  hotkeys('a', 'issues', example);\n  hotkeys.unbind('a', 'issues', example);\n}\n```\n\nTo unbind everything.\n\n```js\nhotkeys.unbind();\n```\n\n### isPressed\n\nFor example, `hotkeys.isPressed(77)` is true if the `M` key is currently pressed.\n\n```js\nhotkeys('a', function() {\n  console.log(hotkeys.isPressed('a')); //=> true\n  console.log(hotkeys.isPressed('A')); //=> true\n  console.log(hotkeys.isPressed(65)); //=> true\n});\n```\n\n### trigger\n\ntrigger shortcut key event\n\n```js\nhotkeys.trigger('ctrl+o');\nhotkeys.trigger('ctrl+o', 'scope2');\n```\n\n### getPressedKeyCodes\n\nReturns an array of key codes currently pressed.\n\n```js\nhotkeys('command+ctrl+shift+a,f', function() {\n  console.log(hotkeys.getPressedKeyCodes()); //=> [17, 65] or [70]\n})\n```\n\n### getPressedKeyString\n\nReturns an array of key codes currently pressed.\n\n```js\nhotkeys('command+ctrl+shift+a,f', function() {\n  console.log(hotkeys.getPressedKeyString()); \n  //=> ['⌘', '⌃', '⇧', 'A', 'F']\n})\n```\n\n### getAllKeyCodes\n\nGet a list of all registration codes.\n\n```js\nhotkeys('command+ctrl+shift+a,f', function() {\n  console.log(hotkeys.getAllKeyCodes());\n  // [\n  //   { \n  //      scope: 'all', \n  //      shortcut: 'command+ctrl+shift+a', \n  //      mods: [91, 17, 16], \n  //      keys: [91, 17, 16, 65] \n  //    },\n  //   { scope: 'all', shortcut: 'f', mods: [], keys: [42] }\n  // ]\n})\n```\n\n### filter\n\nBy default hotkeys are not enabled for `INPUT` `SELECT` `TEXTAREA` elements. `Hotkeys.filter` to return to the `true` shortcut keys set to play a role, `false` shortcut keys set up failure.\n\n```js\nhotkeys.filter = function(event){\n  return true;\n}\n// How to add the filter to edit labels. \n// <div contentEditable=\"true\"></div>\n// \"contentEditable\" Older browsers that do not support drops\nhotkeys.filter = function(event) {\n  var target = event.target || event.srcElement;\n  var tagName = target.tagName;\n  return !(\n    target.isContentEditable || \n    tagName == 'INPUT' || \n    tagName == 'SELECT' || \n    tagName == 'TEXTAREA'\n  );\n}\n\nhotkeys.filter = function(event){\n  var tagName = (event.target || event.srcElement).tagName;\n  hotkeys.setScope(\n    /^(INPUT|TEXTAREA|SELECT)$/.test(tagName) ? 'input' : 'other'\n  );\n  return true;\n}\n```\n\n### noConflict\n\nRelinquish HotKeys’s control of the `hotkeys` variable.\n\n```js\nvar k = hotkeys.noConflict();\nk('a', function() {\n  console.log(\"do something\")\n});\n\nhotkeys()\n// -->Uncaught TypeError: hotkeys is not a function(anonymous function)\n// @ VM2170:2InjectedScript._evaluateOn\n// @ VM2165:883InjectedScript._evaluateAndWrap\n// @ VM2165:816InjectedScript.evaluate @ VM2165:682\n```\n\n## Development\n\nTo develop, Install dependencies, Get the code:\n\n```shell\n$ git https://github.com/jaywcjlove/hotkeys.git\n$ cd hotkeys     # Into the directory\n$ npm install    # or  yarn install\n```\n\nTo develop, run the self-reloading build:\n\n```shell\n$ npm run watch\n```\n\nRun Document Website Environment.\n\n```shell\n# Generate documentation website\n$ npm run doc \n# Live-generate documentation website\n$ npm run start \n```\n\nTo contribute, please fork Hotkeys.js, add your patch and tests for it (in the `test/` folder) and submit a pull request.\n\n```shell\n$ npm run test\n$ npm run test:watch # Development model\n```\n\n## Contributors\n\nAs always, thanks to our amazing contributors!\n\n<a href=\"https://github.com/jaywcjlove/hotkeys-js/graphs/contributors\">\n  <img src=\"https://jaywcjlove.github.io/hotkeys-js/CONTRIBUTORS.svg\" />\n</a>\n\nMade with [action-contributors](https://github.com/jaywcjlove/github-action-contributors).\n\nSpecial thanks to [@dimensi](https://github.com/dimensi) for the refactoring of version [4.0](https://github.com/jaywcjlove/hotkeys-js/issues/313).\n\n## License\n\n[MIT © Kenny Wong](./LICENSE)\n","publish_time":1766424953676,"_cnpm_publish_time":1766424953676,"dist-tags":{"latest":"4.1.2"}}