Last active
January 18, 2018 19:34
-
-
Save Inobtenio/f0c8129759d5292741ae18af63a6dc96 to your computer and use it in GitHub Desktop.
Control video playback with your keys in case is not supported natively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).keydown(function(event){ | |
var player = $('video')[0] | |
if (event.keyCode == 39 || event.keyCode == 68){ | |
player.currentTime = player.currentTime + 10 | |
} else if (event.keyCode == 37 || event.keyCode == 65){ | |
player.currentTime = player.currentTime - 10 | |
} else if (event.keyCode == 32){ | |
event.preventDefault(); | |
if (player.paused){ | |
player.play() | |
} else{ | |
player.pause() | |
} | |
} else if (event.keyCode == 38){ | |
event.preventDefault(); | |
player.volume += 0.1; | |
} else if (event.keyCode == 40){ | |
event.preventDefault(); | |
player.volume -= 0.1; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment