Solved

Esc key - Keyboard event in Actionscript 3

Posted on 2009-07-16
5
6,315 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 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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

688 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