Last active
August 29, 2015 13:57
-
-
Save murtaugh/9924509 to your computer and use it in GitHub Desktop.
Keyboard Controls
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.onkeydown = checkKey; | |
function checkKey(e) { | |
e = e || window.event; | |
if ((e.keyCode == '39') || (e.keyCode == '40')) { // right / down arrow | |
console.log('right / down'); | |
} else if ((e.keyCode == '37') || (e.keyCode == '38')) { // left / up arrow | |
console.log('left / up'); | |
} else if (e.keyCode == '32') { // space bar | |
console.log('space'); | |
} else if (e.keyCode == '27') { // esc key | |
console.log('esc'); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment