Handling keyboard events globally : KeyboardEvent : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » KeyboardEvent »

 

Handling keyboard events globally


 
package {
  import flash.display.*;
  import flash.events.*;

  public class Main extends Sprite {
    public function Main (  ) {
      stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
    }

    private function keyDownListener (e:KeyboardEvent):void {
      trace("A key was pressed.");
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» KeyboardEvent