Link to home
Start Free TrialLog in
Avatar of whatisittellme
whatisittellme

asked on

Esc key - Keyboard event in Actionscript 3

I am trying to associate an action to Escape-key event in AS3 using the following code.
The problem is that the event is triggered (rather 'pressed escape' is printed) only when I press Shift+Escape and not just Escape.
I want it to work with just Escape key.

I would greatly appreciate if anyone can point me to the mistake I am making. Thanks.
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
function KeyPressed(evnt:KeyboardEvent){
	switch (evnt.keyCode) {
	case Keyboard.ESCAPE :
	trace("pressed escape")
	break;
	case Keyboard.RIGHT :
	trace("RIGHT");
	break;
	case Keyboard.LEFT :
	trace("LEFT");
	break;
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of TheDauntless
TheDauntless
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of whatisittellme
whatisittellme

ASKER

I was testing it in flash. I need it to run in a browser when it is finally complete. Thanks for your help. I dint realize that it is working in a browser already !
Hi!!
Are you talking about the Control menu??  I am not finding the option "Disable keyboard shortcuts" there.
Where to find this option.  Please clarify.
Thanks in advance.
It's in the control menu of the Flash player playing your SWF, not Flash's Control menu.

So in flash, run your movie (ctrl + enter) and THEN look for 'Disable Keyboard shortcuts' in the Control menu.
oh!! cool!!
got it now..
thanks dauntless