diff --git a/src/plugins/bookPlayer/plugin.js b/src/plugins/bookPlayer/plugin.js index f43613be5..609bb92e8 100644 --- a/src/plugins/bookPlayer/plugin.js +++ b/src/plugins/bookPlayer/plugin.js @@ -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)); diff --git a/src/plugins/comicsPlayer/plugin.js b/src/plugins/comicsPlayer/plugin.js index 405bdcd94..f1a0437c5 100644 --- a/src/plugins/comicsPlayer/plugin.js +++ b/src/plugins/comicsPlayer/plugin.js @@ -23,7 +23,7 @@ export class ComicsPlayer { this.imageMap = new Map(); this.onDialogClosed = this.onDialogClosed.bind(this); - this.onWindowKeyUp = this.onWindowKeyUp.bind(this); + this.onWindowKeyDown = this.onWindowKeyDown.bind(this); } play(options) { @@ -177,7 +177,7 @@ export class ComicsPlayer { this.swiperInstance.update(); } - onWindowKeyUp(e) { + onWindowKeyDown(e) { const key = keyboardnavigation.getKeyName(e); if (key === 'Escape') { this.stop(); @@ -196,7 +196,7 @@ export class ComicsPlayer { bindEvents() { this.bindMediaElementEvents(); - document.addEventListener('keyup', this.onWindowKeyUp); + document.addEventListener('keydown', this.onWindowKeyDown); } unbindMediaElementEvents() { @@ -211,7 +211,7 @@ export class ComicsPlayer { unbindEvents() { this.unbindMediaElementEvents(); - document.removeEventListener('keyup', this.onWindowKeyUp); + document.removeEventListener('keydown', this.onWindowKeyDown); } createMediaElement() { diff --git a/src/plugins/pdfPlayer/plugin.js b/src/plugins/pdfPlayer/plugin.js index f138125e8..f5710c332 100644 --- a/src/plugins/pdfPlayer/plugin.js +++ b/src/plugins/pdfPlayer/plugin.js @@ -18,7 +18,7 @@ export class PdfPlayer { this.priority = 1; this.onDialogClosed = this.onDialogClosed.bind(this); - this.onWindowKeyUp = this.onWindowKeyUp.bind(this); + this.onWindowKeyDown = this.onWindowKeyDown.bind(this); this.onTouchStart = this.onTouchStart.bind(this); } @@ -88,7 +88,7 @@ export class PdfPlayer { return true; } - onWindowKeyUp(e) { + onWindowKeyDown(e) { if (!this.loaded) return; const key = keyboardnavigation.getKeyName(e); @@ -133,7 +133,7 @@ export class PdfPlayer { bindEvents() { this.bindMediaElementEvents(); - document.addEventListener('keyup', this.onWindowKeyUp); + document.addEventListener('keydown', this.onWindowKeyDown); document.addEventListener('touchstart', this.onTouchStart); } @@ -149,7 +149,7 @@ export class PdfPlayer { this.unbindMediaElementEvents(); } - document.removeEventListener('keyup', this.onWindowKeyUp); + document.removeEventListener('keydown', this.onWindowKeyDown); document.removeEventListener('touchstart', this.onTouchStart); }