?
Solved

Esc key - Keyboard event in Actionscript 3

Posted on 2009-07-16
5
Medium Priority
?
6,341 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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.

762 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