key navigation

This commit is contained in:
Matt Walsh 2022-12-19 11:48:59 -06:00
parent 7cf9dd6466
commit 97e0fda709

View file

@ -290,37 +290,41 @@ const updateFullScreenNavigate = () => {
}; };
const documentKeydown = (e) => { const documentKeydown = (e) => {
const code = (e.keyCode || e.which); const { key } = e;
// 200ms repeat
if ((Date.now() - documentKeydown.lastButton ?? 0) < 200) return false;
documentKeydown.lastButton = Date.now();
if (document.fullscreenElement || document.activeElement === document.body) { if (document.fullscreenElement || document.activeElement === document.body) {
switch (code) { switch (key) {
case 32: // Space case ' ': // Space
// don't scroll
e.preventDefault();
btnNavigatePlayClick(); btnNavigatePlayClick();
return false; return false;
case 39: // Right Arrow case 'ArrowRight':
case 34: // Page Down case 'PageDown':
// don't scroll
e.preventDefault();
btnNavigateNextClick(); btnNavigateNextClick();
return false; return false;
case 37: // Left Arrow case 'ArrowLeft':
case 33: // Page Up case 'PageUp':
// don't scroll
e.preventDefault();
btnNavigatePreviousClick(); btnNavigatePreviousClick();
return false; return false;
case 36: // Home case 'ArrowUp': // Home
e.preventDefault();
btnNavigateMenuClick(); btnNavigateMenuClick();
return false; return false;
case 48: // Restart case '0': // "O" Restart
btnNavigateRefreshClick(); btnNavigateRefreshClick();
return false; return false;
case 70: // F case 'F':
case 'f':
btnFullScreenClick(); btnFullScreenClick();
return false; return false;