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