export default class Key { constructor(name) { this.name = name; this.pressed = false; window.addEventListener( 'keydown', (event) => { if (event.code === this.name) { this.pressed = true; } } ); window.addEventListener( 'keyup', (event) => { if (event.code === this.name) { this.pressed = false; } } ); } isPressed() { return this.pressed; } }