user-input-keyboard

0.4.3 • Public • Published

user-input-keyboard

Keyboard input tracking as 0 or 1.

Useful for applications which require tracking of key states.

Usage

NPM

Example

var keyboard = window.keyboardInput(document)

When the user presses "A", keyboard will contain the following.

{
    "A": 1
}

When the user releases "A", and then presses "F", keyboard will contain the following.

{
    "A": 0,
    "F": 1
}

Intercepting Events

Events can be intercepted using the afterEvent option.

var keyboard = window.keyboardInput(document, {
    afterEvent: (key, event) => {
        // key   === vkey string of key pressed
        // event === original keyboard event
    }
})

Tests

  • Mocha
    • Test functionality in Node.js
    • npm test
  • User Test
    • Test functionality in browser.
    • npm user-test

Readme

Keywords

Package Sidebar

Install

npm i user-input-keyboard

Weekly Downloads

1

Version

0.4.3

License

MIT

Unpacked Size

5 kB

Total Files

5

Last publish

Collaborators

  • apexearth