Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Esc key - Keyboard event in Actionscript 3

Posted on 2009-07-16
5
Medium Priority
?
6,360 Views
Last Modified: 2013-11-11
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

0
Comment
Question by:whatisittellme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
TheDauntless earned 2000 total points
ID: 24877564
You're probably testing in Flash? If you check "Control -> Disable Keyboard Shortcuts" it should work. (It should also work right away in your browser)
0
 
LVL 2

Author Closing Comment

by:whatisittellme
ID: 31604331
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 !
0
 

Expert Comment

by:Nakul
ID: 24959137
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.
0
 
LVL 6

Expert Comment

by:TheDauntless
ID: 24959396
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.
0
 

Expert Comment

by:Nakul
ID: 24960243
oh!! cool!!
got it now..
thanks dauntless
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question