From efdffb365a781c4fce5cee26e509c6df65451076 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 31 Mar 2023 08:28:46 -0700 Subject: [PATCH] prevent keyboard events from reaching player (#459) --- tubearchivist/static/script.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tubearchivist/static/script.js b/tubearchivist/static/script.js index ff8e8cc5..598f4e92 100644 --- a/tubearchivist/static/script.js +++ b/tubearchivist/static/script.js @@ -1402,7 +1402,8 @@ function recordTextTrackChanges() { } // keyboard shortcuts for the video player -document.addEventListener('keydown', doShortcut); +// need useCapture so we can prevent events from reaching the player +document.addEventListener('keydown', doShortcut, true); let modalHideTimeout = -1; function showModal(html, duration) { @@ -1458,19 +1459,13 @@ function doShortcut(e) { break; } case 'ArrowLeft': { - if (targetName === 'video') { - // hitting arrows while the video is focused will use the built-in skip - break; - } + e.preventDefault(); showModal('- 5 seconds', 500); player.currentTime -= 5; break; } case 'ArrowRight': { - if (targetName === 'video') { - // hitting space while the video is focused will use the built-in skip - break; - } + e.preventDefault(); showModal('+ 5 seconds', 500); player.currentTime += 5; break; @@ -1493,10 +1488,6 @@ function doShortcut(e) { break; } case ' ': { - if (targetName === 'video') { - // hitting space while the video is focused will toggle it anyway - break; - } e.preventDefault(); if (player.paused) { player.play();