Provides keydown and keyup events using vkey to developers using Node.js to develop for browsers.
const keyevents = require('key-events') // Also at window.keyevents.
// Default target is: document.body
// Default events are: ['keyup', 'keydown']
var keys = keyevents()
keys.on("keydown", function(key, event) {
console.log(key) // A vkey value based on the key pressed.
console.log(event) // The original event received.
})
keys.on("keyup", function(key, event) {
console.log(key) // A vkey value based on the key pressed.
console.log(event) // The original event received.
})
var keys = window.keyevents(document) // Default target is `document.body`
var keys = window.keyevents(['keypress']) // Default target is `document.body`
keys.on("keypress", function(key, event) {
console.log(key) // A vkey value based on the key pressed.
console.log(event) // The original event received.
})
var keys = window.keyevents(document, ['keypress']) // Default target is `document.body`
keys.on("keypress", function(key, event) {
console.log(key) // A vkey value based on the key pressed.
console.log(event) // The original event received.
})
- Mocha
- Test functionality in Node.js
- Karma
- Using browserify, test functionality in browsers
- User Testing
- grunt user-test is set to build, serve, and open test/index.html