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
Solved

Esc key - Keyboard event in Actionscript 3

Posted on 2009-07-16
5
6,282 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
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
TheDauntless earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

791 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