Skip to content

Instantly share code, notes, and snippets.

@oisincar
Created December 17, 2016 13:37
Show Gist options
  • Save oisincar/849353e82a1049863823122a434dd497 to your computer and use it in GitHub Desktop.
Save oisincar/849353e82a1049863823122a434dd497 to your computer and use it in GitHub Desktop.
$(document).keydown(function(e) {
switch(e.which) {
case 'h': // left
createjs.Sound.play((wordNumber = (wordNumber %5) + 1) + "_1", createjs.Sound.INTERRUPT_NONE, 0, 0, false, 1);
break;
case 'j': // up
createjs.Sound.play((wordNumber = (wordNumber %5) + 1) + "_2", createjs.Sound.INTERRUPT_NONE, 0, 0, false, 1);
break;
case 'k': // right
createjs.Sound.play((wordNumber = (wordNumber %5) + 1) + "_3", createjs.Sound.INTERRUPT_NONE, 0, 0, false, 1);
break;
case 'l': // down
createjs.Sound.play((wordNumber = (wordNumber %5) + 1) + "_4", createjs.Sound.INTERRUPT_NONE, 0, 0, false, 1);
break;
case ';': // down
createjs.Sound.play((wordNumber = (wordNumber %5) + 1) + "_5", createjs.Sound.INTERRUPT_NONE, 0, 0, false, 1);
break;
default: return; // exit this handler for other keys
}
e.preventDefault(); // prevent the default action (scroll / move caret)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment