this is how we did it in darkchat (maybe a better way).
first do a onKeyPressed on your node:
1 2 3
| onKeyPressed: function(e:KeyEvent):Void { handleKeyInput(e.code.toString().trim()); } |
then do a onKeyTyped on the same node:
1 2 3
| onKeyTyped: function(e:KeyEvent):Void { handleKeyInput(e.char.toString().trim()); } |
then call a function to work out if it was a code or a char:
1 2 3 4 5 6 7 8 9 10 11 12
| function handleKeyInput( keyInput ) { if ( keyInput.length() == 1 ) { .... } else { .... if ( keyInput == "VK_BACK_SPACE") { .... } } } |
bit hackie imo, but what can you do?