Listen for a Keyboard Event
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300" keyDown="keyHandler(event)" backgroundColor="#0000ff"> <mx:Script> import flash.events.KeyboardEvent; private function keyHandler(event:KeyboardEvent):void { switch(event.keyCode) { case 13: trace(" Enter pressed "); break; case 32: trace(" Space Bar pressed "); break; case 16: trace(" Shift Key pressed "); break; case 112: trace(" F1 pressed "); break; case 8: trace(" Delete pressed "); break; } } </mx:Script> <mx:Button label="One"/> </mx:HBox> </mx:Application>