Skip to content

Instantly share code, notes, and snippets.

@Inobtenio
Last active January 18, 2018 19:34
Show Gist options
  • Save Inobtenio/f0c8129759d5292741ae18af63a6dc96 to your computer and use it in GitHub Desktop.
Save Inobtenio/f0c8129759d5292741ae18af63a6dc96 to your computer and use it in GitHub Desktop.
Control video playback with your keys in case is not supported natively
$(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