Skip to content

Instantly share code, notes, and snippets.

@a-eid a-eid/video.js
Last active Aug 3, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.