bind to a key map
component install entity/keys
var map = {
37: 'left',
38: 'up',
39: 'right',
40: 'down'
};
var keys = require('keys')(map);
document.body.onkeydown = keys.onkeydown;
document.body.onkeyup = keys.onkeyup;
var log = console.log.bind(console);
keys.on('keydown', log);
keys.on('keyup', log);
keys.on('change', log);
Creates key map
handler.
map
is an object with keycode property names
where their corresponding values are emitted
on keyup/down events.
keydown
(event, key)keyup
(event, key)change
(event, key, state)
MIT