/ Published in: ActionScript 3
Use this code to handle keypress/keyboard events
Expand |
Embed | Plain Text
public function init():void { txtBox.addEventListener(KeyboardEvent.KEY_UP,pressEscape); } public function pressEscape(event:KeyboardEvent):void { if (event.keyCode==13) { Alert.show("Enter Key has been pressed"); } }
Comments
Subscribe to comments
You need to login to post a comment.

this one differs the four keyboard keys, when added these you can add interactivity for example to program games etc... or use it as an intuitive website navigation..
import flash.events.KeyboardEvent; import flashx.textLayout.elements.BreakElement;
init(); function init():void { stage.addEventListener(KeyboardEvent.KEY_UP,pressEscape); }
function pressEscape(event:KeyboardEvent):void {
}