Created
December 5, 2019 22:43
-
-
Save asolera/ec2a84f6f200ff987dd4ebdabf367e4a to your computer and use it in GitHub Desktop.
Add forward and backward feature to your HTML5 videos using keyboard arrows (left and right)
This file contains 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
const secondsToSkip = 3; | |
let video = document.getElementById("video-player_html5_api"); | |
document.onkeydown = (event) => { | |
if (event.keyCode == 37) video.currentTime = video.currentTime - secondsToSkip; | |
if (event.keyCode == 39) video.currentTime = video.currentTime + secondsToSkip; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment