Only prevent default on valid keyboard shortcuts

This commit is contained in:
Preston 2020-09-26 11:57:57 -04:00
parent 75ab24e47a
commit 91069658c8
1 changed files with 23 additions and 1 deletions

View File

@ -405,121 +405,143 @@ export default Vue.extend({
}
if (this.player !== null) {
event.preventDefault()
switch (event.which) {
case 32:
// Space Bar
// Toggle Play/Pause
event.preventDefault()
this.togglePlayPause()
break
case 74:
// J Key
// Rewind by 10 seconds
event.preventDefault()
this.changeDurationBySeconds(-10)
break
case 75:
// K Key
// Toggle Play/Pause
event.preventDefault()
this.togglePlayPause()
break
case 76:
// L Key
// Fast Forward by 10 seconds
event.preventDefault()
this.changeDurationBySeconds(10)
break
case 79:
// O Key
// Decrease playback rate by 0.25x
event.preventDefault()
this.changePlayBackRate(-0.25)
break
case 80:
// P Key
// Increase playback rate by 0.25x
event.preventDefault()
this.changePlayBackRate(0.25)
break
case 70:
// F Key
// Toggle Fullscreen Playback
event.preventDefault()
this.toggleFullscreen()
break
case 77:
// M Key
// Toggle Mute
event.preventDefault()
this.toggleMute()
break
case 67:
// C Key
// Toggle Captions
event.preventDefault()
this.toggleCaptions()
break
case 38:
// Up Arrow Key
// Increase volume
event.preventDefault()
this.changeVolume(0.05)
break
case 40:
// Down Arrow Key
// Descrease Volume
event.preventDefault()
this.changeVolume(-0.05)
break
case 37:
// Left Arrow Key
// Rewind by 5 seconds
event.preventDefault()
this.changeDurationBySeconds(-5)
break
case 39:
// Right Arrow Key
// Fast Foward by 5 seconds
event.preventDefault()
this.changeDurationBySeconds(5)
break
case 49:
// 1 Key
// Jump to 10% in the video
event.preventDefault()
this.changeDurationByPercentage(0.1)
break
case 50:
// 2 Key
// Jump to 20% in the video
event.preventDefault()
this.changeDurationByPercentage(0.2)
break
case 51:
// 3 Key
// Jump to 30% in the video
event.preventDefault()
this.changeDurationByPercentage(0.3)
break
case 52:
// 4 Key
// Jump to 40% in the video
event.preventDefault()
this.changeDurationByPercentage(0.4)
break
case 53:
// 5 Key
// Jump to 50% in the video
event.preventDefault()
this.changeDurationByPercentage(0.5)
break
case 54:
// 6 Key
// Jump to 60% in the video
event.preventDefault()
this.changeDurationByPercentage(0.6)
break
case 55:
// 7 Key
// Jump to 70% in the video
event.preventDefault()
this.changeDurationByPercentage(0.7)
break
case 56:
// 8 Key
// Jump to 80% in the video
event.preventDefault()
this.changeDurationByPercentage(0.8)
break
case 57:
// 9 Key
// Jump to 90% in the video
event.preventDefault()
this.changeDurationByPercentage(0.9)
break
case 48:
// 0 Key
// Jump to 0% in the video (The beginning)
event.preventDefault()
this.changeDurationByPercentage(0)
break
}