Listen for the keyDown event and traces out the character code for that key. : KeyboardEvent : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » KeyboardEvent »

 

Listen for the keyDown event and traces out the character code for that key.


 

package {
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    
    public class Main extends Sprite {
        public function Main(  ) {
            stage.focus = this;
            addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
        }
        
        private function onKeyDown(event:KeyboardEvent):void {
            trace("key down: " + event.charCode);
        }
    }
}

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo Development
» KeyboardEvent