Single handler for all browser keyboard events.
Appends a single listener for keyboard events, using the document.addEventListener
function. See the API section for available helper functions, when key(s) are pressed and released.
$ npm install --save keyboard-handler
or
$ pnpm add keyboard-handler
import * as keyboard from 'keyboard-handler'
keyboard.keyPressed(e => {
console.log(e.key)
})
// => 'Enter'
Calls cb
if all keys
are held down.
Type: array
Type: function
Calls cb
when a certain key key
is pressed.
Type: string
Type: function
Calls cb
when any key is pressed.
Type: function
Calls cb
when any key is released.
Type: function
MIT © Emil Johansson