Create the global listener for handling the keyboard event
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="init()">
<mx:Script>
import mx.controls.Alert;
import flash.events.KeyboardEvent;
private function init():void
{
this.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler );
}
private function keyHandler (evt:KeyboardEvent):void
{
myText.text += "The key with the keycode" + evt.keyCode + " \n";
}
</mx:Script>
<mx:TextArea id="myText" editable="false"/>
</mx:Application>
Related examples in the same category