Last active
August 29, 2015 14:18
-
-
Save rococodogs/c573737896427db0977a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
document.addEventListener('keydown', function(ev) { | |
var audio = document.getElementById('audioplayer') | |
, okayKeys = [32, 37, 39] | |
; | |
if (okayKeys.indexOf(ev.keyCode) > -1) { | |
ev.preventDefault(); | |
} | |
// space (pause) | |
if (ev.keyCode === 32) { | |
audio.paused ? audio.play() : audio.pause(); | |
} | |
// left arrow (back) | |
else if (ev.keyCode === 37) { | |
audio.currentTime -= parseInt(document.querySelector('#seekbackbutton').getAttribute('data-seek-back-interval')); | |
} | |
// right arrow (fwd) | |
else if (ev.keyCode === 39) { | |
audio.currentTime += parseInt(document.querySelector('#seekforwardbutton').getAttribute('data-seek-forward-interval')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment