Skip to content

Instantly share code, notes, and snippets.

@renesansz
Last active September 8, 2015 14:09
Show Gist options
  • Save renesansz/a1e465845b84f5dc98c6 to your computer and use it in GitHub Desktop.
Save renesansz/a1e465845b84f5dc98c6 to your computer and use it in GitHub Desktop.
Key Press Listener for JavaScript
'use strict';
(function(window){
/**
* Function: Keydown
*
* Manipulate keypress actions.
*
* Parameters:
* (Object) evt - Keydown object
*
* Returns:
* null
*/
function Keydown(evt) {
switch (evt.keyCode) { // keyCode source: http://www.asquare.net/javascript/tests/KeyCode.html
case 38: // Up
case 37: // Left
case 39: // Right
case 40: // Down
break;
}
}
window.onkeydown = Keydown;
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment