Last active
September 8, 2015 14:09
-
-
Save renesansz/a1e465845b84f5dc98c6 to your computer and use it in GitHub Desktop.
Key Press Listener for JavaScript
This file contains 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
'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