3.0.7 • Published 2 years ago

keyboard-handler v3.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

keyboard-handler npm version

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.

Install

$ npm install --save keyboard-handler

or

$ pnpm add keyboard-handler

Usage

import * as keyboard from 'keyboard-handler'
keyboard.keyPressed(e => {
	console.log(e.key)
})
// => 'Enter'

API

keysAreDown(keys, cb)

Calls cb if all keys are held down.

keys

Type: array

cb

Type: function

keyIsDown(key, cb)

Calls cb when a certain key key is pressed.

key

Type: string

cb

Type: function

keyPressed(cb)

Calls cb when any key is pressed.

cb

Type: function

keyReleased(cb)

Calls cb when any key is released.

cb

Type: function

License

MIT © Emil Johansson

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

3.0.0-next.0

2 years ago

2.0.0

7 years ago

1.1.3

7 years ago

1.1.2

8 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago

0.0.1

9 years ago