boxes/js/input.mjs
2023-06-24 14:15:27 +02:00

11 lines
273 B
JavaScript

export function on_press (key, callback) {
document.body.addEventListener("keydown", e => {
if (e.key === key) callback(key);
});
}
export function on_release (key, callback) {
document.body.addEventListener("keyup", e => {
if (e.key === key) callback(key);
});
}