AS3 Left and Right Cursor Key Presses


/ Published in: ActionScript 3



Copy this code and paste it in your HTML
  1. import flash.ui.Keyboard;
  2. import flash.events.KeyboardEvent;
  3.  
  4. stage.addEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
  5.  
  6. private function onStage_KEY_DOWN(event:KeyboardEvent):void
  7. {
  8. switch (event.keyCode)
  9. {
  10. case Keyboard.LEFT:
  11. trace("LEFT");
  12. break;
  13. case Keyboard.RIGHT:
  14. trace("RIGHT");
  15. break;
  16. }
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.