26 lines
722 B
JavaScript
26 lines
722 B
JavaScript
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;
|
|
}
|
|
}
|
|
}
|