Skip to content

Instantly share code, notes, and snippets.

@a-eid
Last active August 3, 2019 18:52
Show Gist options
  • Save a-eid/5d4d9dc858d14b381bce349ea934aa9f to your computer and use it in GitHub Desktop.
Save a-eid/5d4d9dc858d14b381bce349ea934aa9f to your computer and use it in GitHub Desktop.
const video = () => document.querySelector("video")
const codes = {
space: 32,
j: 74,
k: 75,
l: 76,
}
document.addEventListener("keydown", e => {
if ( e.keyCode == codes.k ) {
toggle()
}
if (e.keyCode == codes.l) forward()
if (e.keyCode == codes.j) backword()
})
function forward() {
video().currentTime = video().currentTime + 10
}
function backword() {
video().currentTime = video().currentTime - 10
}
function toggle() {
video().paused ? video().play() : video().pause()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment