Skip to content

Commit

Permalink
Hotkeys in active mode for #15
Browse files Browse the repository at this point in the history
  • Loading branch information
1999 committed Oct 16, 2013
1 parent 67bdd28 commit ed17ba9
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/layout/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,47 @@ parallel({
// @see https://code.google.com/p/chromium/issues/detail?id=90793
document.addEventListener("webkitvisibilitychange", function () {
Navigation.appWindowVisible = !document.webkitHidden;
console.log(document.webkitHidden);
}, false);

// hotkeys
document.addEventListener("keyup", function (evt) {
if (evt.target !== document.body || document.body.hasClass("guest")) {
return;
}

var playerIsPaused = $("footer .pause").hasClass("hidden");

switch (evt.keyCode) {
case 32: // space
case 179: // multimedia.play-pause
if (playerIsPaused) {
Sounds.play();
} else {
Sounds.pause();
}

break;

case 13: // return
if (!playerIsPaused) {
Sounds.updateCurrentTime(0);
}

break;

case 37: // left
case 177: // multimedia.back
Sounds.playPrev();
break;

case 39: // right
case 176: // multimedia.forward
Sounds.playNext();
break;

case 178: // multimedia.stop
break;
}
}, false);

document.body.bind("submit", function (evt) {
Expand Down

0 comments on commit ed17ba9

Please sign in to comment.