Refactor key registration to use this.scope.register

This commit is contained in:
Lutu-gl 2025-04-02 18:36:51 +02:00
parent f0fe69029d
commit c63b23c2e1

13
main.ts
View file

@ -104,13 +104,14 @@ class QuestionsModal extends Modal {
bgEl.classList.add("quiz-no-blur");
}
this.registerKeys();
this.render();
}
this.scope.register([], 'Enter', () => {
this.toggleAnswer();
});
this.scope.register([], ' ', () => {
this.toggleAnswer();
});
registerKeys() {
this.handleKeyPress = this.handleKeyPress.bind(this);
this.component.registerDomEvent(window, "keydown", this.handleKeyPress);
this.render();
}
handleKeyPress(event: KeyboardEvent) {