prevent keyboard events from reaching player (#459)

This commit is contained in:
Kevin Gibbons 2023-03-31 08:28:46 -07:00 committed by GitHub
parent 75441cdf56
commit efdffb365a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 13 deletions

View File

@ -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();