assassin-bug/framework/ui/text/keyboard-manager.js

26 lines
722 B
JavaScript
Raw Normal View History

2022-11-26 01:22:02 +00:00
export class KeyboardManager {
constructor(scrollingText) {
this.scrollingText = scrollingText;
}
init() {
this.scrollingText
.getContainer()
.addEventListener('keydown', (event) => this.handler(event));
}
release() {
this.scrollingText
.getContainer()
.removeEventListener('keydown', (event) => this.handler(event));
}
handler(event) {
switch (event.key) {
case 'Enter':
event.preventDefault();
this.scrollingText.getCurrentLine().getAdvanceButton().click();
break;
default:
break;
}
}
}