hotkey-listener
A modest js library that dispatches low-level keyboard events in the form of CustomEvents.
Issues
Hotkey listener is 5.99kb according to Unpkg. https://unpkg.com/browse/hotkey-listener/
Hotkey Listener is 2.6kb GZipped according to Bundlephobia. https://bundlephobia.com/result?p=hotkey-listener@0.0.3
Hotkey Listener can only be registered on HTMLElement
's that implement
the "KeyboardEvent" interface.
For example: window
, document
Installation
npm install hotkey-listener ## OR yarn add hotkey-listener
Usage
// index.js hotkeyListener window window
Hotkey listener creates custom keyup:<keystroke>
and keydown:<keystroke>
events.
Events also record the key that was pressed via event.detail.key
API Reference
hotkeyListener
Hotkeys API
Should you need more finely grained tuning of hotkeys
, you can
communicate with the hotkeys
API directly. For example, to enable
hotkeys on input
, textarea
, etc, you can do the following:
import hotkeyListener from "hotkey-listener"
https://github.com/jaywcjlove/hotkeys#filter
How it works?
Hotkey-Listener under the hood uses the hotkeys
library to dispatch CustomEvents to the client.