Skip to content

Instantly share code, notes, and snippets.

@asolera
Created December 5, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolera/ec2a84f6f200ff987dd4ebdabf367e4a to your computer and use it in GitHub Desktop.
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)
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