user-input-keyboard
v0.4.3
Published
Keyboard input tracking as 0 or 1.
Downloads
9
Readme
user-input-keyboard
Keyboard input tracking as 0 or 1.
Useful for applications which require tracking of key states.
Usage
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