Key listeners fix

This commit is contained in:
Sam Potts 2017-11-05 20:49:37 +11:00
parent 374de800a4
commit 6bebbe4153
3 changed files with 7 additions and 9 deletions

2
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

2
dist/plyr.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -151,11 +151,9 @@ const listeners = {
}; };
// Get the key code for an event // Get the key code for an event
function getKeyCode(event) { const getKeyCode = event => (event.keyCode ? event.keyCode : event.which);
return event.keyCode ? event.keyCode : event.which;
}
function handleKey(event) { const handleKey = event => {
const code = getKeyCode(event); const code = getKeyCode(event);
const pressed = event.type === 'keydown'; const pressed = event.type === 'keydown';
const held = pressed && code === last; const held = pressed && code === last;
@ -167,10 +165,10 @@ const listeners = {
} }
// Seek by the number keys // Seek by the number keys
function seekByKey() { const seekByKey = () => {
// Divide the max duration into 10th's and times by the number value // Divide the max duration into 10th's and times by the number value
this.currentTime = this.duration / 10 * (code - 48); this.currentTime = this.duration / 10 * (code - 48);
} };
// Handle the key on keydown // Handle the key on keydown
// Reset on keyup // Reset on keyup
@ -306,7 +304,7 @@ const listeners = {
} else { } else {
last = null; last = null;
} }
} };
// Keyboard shortcuts // Keyboard shortcuts
if (this.config.keyboard.focused) { if (this.config.keyboard.focused) {