Skip to content
Permalink
gh-pages
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
26 lines (19 sloc) 482 Bytes
window.addEventListener('keyup', function(event) { Key.onKeyup(event); }, false);
window.addEventListener('keydown', function(event) { Key.onKeydown(event); }, false);
var Key = {
_pressed: {},
A: 65,
W: 87,
D: 68,
S: 83,
SPACE: 32,
isDown: function(keyCode) {
return this._pressed[keyCode];
},
onKeydown: function(event) {
this._pressed[event.keyCode] = true;
},
onKeyup: function(event) {
delete this._pressed[event.keyCode];
}
};