- Notifications
You must be signed in to change notification settings - Fork0
Global DOM element activation
License
JavaScriptExpert/hotkey
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Trigger a action on element when keyboard hotkey is pressed.
Automatically binds hotkeys to any link with adata-hotkeyattribute set. Multiple hotkeys are separated by a,.Key combinations are separated by a+, and key sequencesare separated by a space.
Two-keypress sequences likeg c andg i would be storedunder the 'g' key in a nested object with keys 'c' and 'i'.
mappings = 'c' : <a href="/rails/rails/issues/new" data-hotkey="c">New Issue</a> 'g' : 'c' : <a href="/rails/rails" data-hotkey="g c">Code</a> 'i' : <a href="/rails/rails/issues" data-hotkey="g i">Issues</a>So bothg c andc could be available hotkeys on the samepage, butg c andg couldn't coexist. If the user pressesg, thec hotkey will be unavailable for 1500ms while welisten for eitherg c org i.
$ npm install @github/hotkey<ahref="/page/2"data-hotkey="j">Next</a><ahref="/help"data-hotkey="Control+h">Help</a><ahref="/rails/rails"data-hotkey="g c">Code</a><ahref="/search"data-hotkey="s,/">Search</a>
Seethe list ofKeyboardEvent key values for a list of supported key values.
import{install}from'@github/hotkey'for(constelofdocument.querySelector('[data-hotkey]')){install(el)}
npm installnpm testDistributed under the MIT license. See LICENSE for details.
About
Global DOM element activation
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Languages
- JavaScript100.0%