diff options
author | Sam Potts <me@sampotts.me> | 2016-08-21 19:44:46 +1000 |
---|---|---|
committer | Sam Potts <me@sampotts.me> | 2016-08-21 19:44:46 +1000 |
commit | 4610f4a8c957977e53d596712bce927b390cca68 (patch) | |
tree | 7e46f3afba8c95afa9c11929edc6b0599b980188 /src | |
parent | a8062354ec420bb0c4d90c1e52ae11ac25e10d52 (diff) | |
download | plyr-4610f4a8c957977e53d596712bce927b390cca68.tar.lz plyr-4610f4a8c957977e53d596712bce927b390cca68.tar.xz plyr-4610f4a8c957977e53d596712bce927b390cca68.zip |
Firefox and Edge fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/js/plyr.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 7d3a0c6c..625b0ce0 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -2903,6 +2903,12 @@ var code = getKeyCode(event), pressed = event.type === 'keydown'; + // If the event is bubbled from the media element + // Firefox doesn't get the keycode for whatever reason + if (!_is.number(code)) { + return; + } + // Seek by the number keys function seekByKey() { // Get current duration @@ -2920,6 +2926,14 @@ // Handle the key on keydown // Reset on keyup if (pressed) { + // Which keycodes should we prevent default + var preventDefault = [48,49,50,51,52,53,54,56,57,32,75,38,40,77,39,37,70,67]; + + // If the code is found prevent default (e.g. prevent scrolling for arrows) + if (_inArray(preventDefault, code)) { + event.preventDefault(); + } + switch(code) { // 0-9 case 48: @@ -3155,6 +3169,7 @@ } // Proxy events to container + // Bubble up key events for Edge _on(plyr.media, config.events.concat(['keyup', 'keydown']).join(' '), function(event) { _triggerEvent(plyr.container, event.type, true); }); |