Folder structure

This commit is contained in:
zenoamaro committed 2019-06-30 13:01:53 +02:00
1 parent 946059650f
commit 2ed630a9cd
13 files changed
+2 -2

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import {DEFAULT_KEYPRESS_DELAY} from './constants.js';
const input = {};
let lastKeypressTime = 0;
document.addEventListener('keydown', (e) => {input[e.key] = true; e.preventDefault()});
document.addEventListener('keyup', (e) => {input[e.key] = false; e.preventDefault()});
export function key(key) {
return input[key]
}
export function afterKeyDelay(amount=DEFAULT_KEYPRESS_DELAY) {
const now = Date.now();
if (now - lastKeypressTime >= amount) {
lastKeypressTime = now;
return true;
}
}