Mega Code Archive

 
Categories / Flash ActionScript / Development
 

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);         }     } }