Last active
October 29, 2015 15:11
-
-
Save Stoffo/88fb3d584444a10a4b42 to your computer and use it in GitHub Desktop.
simple event handler to map keycodes of arrow keys to functions.
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
$(window).on('keyup', function (e) { | |
switch (e.keyCode) { | |
/*left*/ | |
case 37: | |
console.log('left'); | |
break; | |
/*right*/ | |
case 39: | |
console.log('right'); | |
break; | |
/*up*/ | |
case 38: | |
console.log('up'); | |
break; | |
/*down*/ | |
case 40: | |
console.log('down'); | |
break; | |
/*escape*/ | |
case 27: | |
console.log('escape'); | |
break; | |
/*enter*/ | |
case 13: | |
console.log('enter'); | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment