simponic.xyz/maize-maze/js/keyboard.js
2024-01-12 19:13:13 -07:00

22 lines
464 B
JavaScript

// 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
};
}());