Use keydown event to get actual modifiers

This commit is contained in:
Dmitry Lyzo
2024-09-14 01:44:52 +03:00
parent d20c617d30
commit 4c68f500d9
3 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -45,7 +45,7 @@ export class BookPlayer {
this.decreaseFontSize = this.decreaseFontSize.bind(this);
this.previous = this.previous.bind(this);
this.next = this.next.bind(this);
this.onWindowKeyUp = this.onWindowKeyUp.bind(this);
this.onWindowKeyDown = this.onWindowKeyDown.bind(this);
this.addSwipeGestures = this.addSwipeGestures.bind(this);
}
@@ -130,7 +130,7 @@ export class BookPlayer {
return true;
}
onWindowKeyUp(e) {
onWindowKeyDown(e) {
const key = keyboardnavigation.getKeyName(e);
if (!this.loaded) return;
@@ -184,8 +184,8 @@ export class BookPlayer {
bindEvents() {
this.bindMediaElementEvents();
document.addEventListener('keyup', this.onWindowKeyUp);
this.rendition?.on('keyup', this.onWindowKeyUp);
document.addEventListener('keydown', this.onWindowKeyDown);
this.rendition?.on('keydown', this.onWindowKeyDown);
if (browser.safari) {
const player = document.getElementById('bookPlayerContainer');
@@ -214,8 +214,8 @@ export class BookPlayer {
this.unbindMediaElementEvents();
}
document.removeEventListener('keyup', this.onWindowKeyUp);
this.rendition?.off('keyup', this.onWindowKeyUp);
document.removeEventListener('keydown', this.onWindowKeyDown);
this.rendition?.off('keydown', this.onWindowKeyDown);
if (!browser.safari) {
this.rendition?.off('rendered', (e, i) => this.addSwipeGestures(i.document.documentElement));