Skip to content

Instantly share code, notes, and snippets.

@cambiata
Created September 8, 2012 09:23
Show Gist options
  • Save cambiata/3673008 to your computer and use it in GitHub Desktop.
Save cambiata/3673008 to your computer and use it in GitHub Desktop.
HaxeNME workaround for KeboardEvent keyCode problem on Neko/Windows targets
/**
* ...
* @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