simponic.xyz/maize-maze/js/keyboard.js

22 lines
464 B
JavaScript
Raw Normal View History

2024-01-12 21:13:13 -05:00
// Shameless stolen code from "Process the Input" presentation
let input = (function() {
function Keyboard() {
let that = {
keys : {}
};
function keyPress(e) {
that.keys[e.key] = e.timeStamp;
}
function keyRelease(e) {
delete that.keys[e.key];
}
window.addEventListener('keydown', keyPress);
window.addEventListener('keyup', keyRelease);
return that;
}
return {
Keyboard : Keyboard
};
}());