prevent keyboard events from reaching player (#459)

pull/474/head
Kevin Gibbons 1 year ago committed by GitHub
parent 75441cdf56
commit efdffb365a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1402,7 +1402,8 @@ function recordTextTrackChanges() {
} }
// keyboard shortcuts for the video player // 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; let modalHideTimeout = -1;
function showModal(html, duration) { function showModal(html, duration) {
@ -1458,19 +1459,13 @@ function doShortcut(e) {
break; break;
} }
case 'ArrowLeft': { case 'ArrowLeft': {
if (targetName === 'video') { e.preventDefault();
// hitting arrows while the video is focused will use the built-in skip
break;
}
showModal('- 5 seconds', 500); showModal('- 5 seconds', 500);
player.currentTime -= 5; player.currentTime -= 5;
break; break;
} }
case 'ArrowRight': { case 'ArrowRight': {
if (targetName === 'video') { e.preventDefault();
// hitting space while the video is focused will use the built-in skip
break;
}
showModal('+ 5 seconds', 500); showModal('+ 5 seconds', 500);
player.currentTime += 5; player.currentTime += 5;
break; break;
@ -1493,10 +1488,6 @@ function doShortcut(e) {
break; break;
} }
case ' ': { case ' ': {
if (targetName === 'video') {
// hitting space while the video is focused will toggle it anyway
break;
}
e.preventDefault(); e.preventDefault();
if (player.paused) { if (player.paused) {
player.play(); player.play();

Loading…
Cancel
Save