Skip to content

Instantly share code, notes, and snippets.

@suren-atoyan
Last active September 26, 2018 06:58
Show Gist options
  • Save suren-atoyan/b6d6d2508225596fb4714317cccda483 to your computer and use it in GitHub Desktop.
Save suren-atoyan/b6d6d2508225596fb4714317cccda483 to your computer and use it in GitHub Desktop.
Snippet for Chrome - When you are using Google Chrome for playing video or audio, but Right and Left arrow buttons don't work properly.
;((d, s) => {
const player = s
? d.querySelector(s)
: d.querySelectorAll('audio')[0]
|| d.querySelectorAll('video')[0];
d.addEventListener('keydown', ({ key }) => key === 'ArrowRight'
? player.currentTime += 5
: key === 'ArrowLeft' && (player.currentTime -= 5)
);
})(document/*, selector <- custom selector*/);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment