Fix Firefox spacebar issue

This commit is contained in:
Sam Potts
2018-08-01 00:37:55 +10:00
parent 3a3358e2b4
commit 56a485bac6
11 changed files with 482 additions and 210 deletions

View File

@ -6,14 +6,7 @@ import controls from './controls';
import ui from './ui';
import { repaint } from './utils/animation';
import browser from './utils/browser';
import {
getElement,
getElements,
hasClass,
matches,
toggleClass,
toggleHidden,
} from './utils/elements';
import { getElement, getElements, hasClass, matches, toggleClass, toggleHidden } from './utils/elements';
import { on, once, toggleListener, triggerEvent } from './utils/events';
import is from './utils/is';
@ -235,7 +228,7 @@ class Listeners {
clearTimeout(this.focusTimer);
// Ignore any key other than tab
if (event.type === 'keydown' && event.code !== 'Tab') {
if (event.type === 'keydown' && event.which !== 9) {
return;
}
@ -699,18 +692,20 @@ class Listeners {
// Settings menu - keyboard toggle
this.bind(
player.elements.buttons.settings,
'keydown',
'keyup',
event => {
// We only care about space
if (event.which !== 32) {
// We only care about space and return
if (event.which !== 32 && event.which !== 13) {
return;
}
// Prevent scroll
event.preventDefault();
// Prevent playing video
event.stopPropagation();
// Prevent playing video (Firefox)
if (event.which === 32) {
event.stopPropagation();
}
// Toggle menu
controls.toggleMenu.call(player, event);