Keyboard events in AS3

To get the character code of something in AS3, add a keyboard event to the stage.

// keyboard event
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
function keyDownHandler(event:KeyboardEvent):void
{
  if (event.keyCode == Keyboard.LEFT) {
  trace("LEFT!");
}
Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑