Created
September 8, 2012 09:23
-
-
Save cambiata/3673008 to your computer and use it in GitHub Desktop.
HaxeNME workaround for KeboardEvent keyCode problem on Neko/Windows targets
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
/** | |
* ... | |
* @author Jonas Nyström | |
*/ | |
class KeyboardTools { | |
/** | |
* Targeting neko and windows, this method returns the sam keycodes for | |
* letters a-z and the numeric keyboard as when targeting flash/html5 | |
*/ | |
static public function getKeyCode(e:KeyboardEvent) { | |
var keyCode = e.keyCode; | |
#if (neko || cpp) | |
if (e.keyCode == e.charCode) | |
if (keyCode >= 65 && keyCode <= 122) { | |
keyCode = keyCode-32; | |
} | |
#end | |
return keyCode; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment