vkeys
problem
some browsers have got an e.key attribute that is submitted with keydown
and keyup
events.
chrome (and other browsers) does not have a e.key attribute.
there are also inconsistencies between different browsers.
solution
@chrisdickinson initiated a project vkey to collect the different definitions and merge
them into a unified definition.
for code that can not handle spaces
, or wants less clutter, this transformation might be useful.
this module transforms the vkey definition, and removes the following clutter:
spaces
<
and>
-
- runs
toLowerCase()
the output is a static key mapping file (without dynamic edge cases): vkeys.js
usage
install
npm install vkeys
use
var vkeys = ; window;
api
vkeys
Object with {code
: key
} pairs.
0: 'unk' ... 8: 'backspace' 9: 'tab' 12: 'clear' 13: 'enter' ... 254: 'clear'
see: vkeys.js
vkeys.getKey(code)
return the key
for the given code
.
var key = vkeys;assert;
vkeys.findCode(key)
returns the first code
that matches the key
.
var code = vkeys;assert;
vkeys.findAllCodes(key)
returns an Array of code
's that match the key
.
var code = vkeys;// code equals [91, 92, 223, 224]
build
- get the latest vkey module:
npm install --save-dev vkey
- run the build:
npm run build
test
npm install -g browserify testlingnpm run test
license
MIT