[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

close popup when 'Esc' key is pressed

Posted on 2011-10-25
5
Medium Priority
?
592 Views
Last Modified: 2012-05-12
hi guys
I have a popup which i am displaying using
PopUpManager.centerPopUp(dataGrid);

When the 'Esc' key is pressed, i want the popup to close. Is that possible?

thanks
0
Comment
Question by:royjayd
  • 2
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
dgofman earned 1200 total points
ID: 37027474
add key event listener for stage

stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
function myKeyDown(e:KeyboardEvent):void {
    if (e.keyCode==Keyboard.ESCAPE) {
         dataGridInstance.deletePopUp();
    }
}
0
 

Author Comment

by:royjayd
ID: 37027566
couple of questions

1.when should i use KEY_UP v/s KEY_DOWN
2. In stage.addEventListener... what does 'stage' mean

thanks
0
 
LVL 29

Expert Comment

by:dgofman
ID: 37027598
please try my example first
0
 

Author Comment

by:royjayd
ID: 37027955
thanks it works

one question i have is
hi
Like you used
if (e.keyCode==Keyboard.ESCAPE) {

Is there a way to check if only alphabets (a-z) or numbers (0-9) is pressed ?

thanks
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 200 total points
ID: 37030231
>> Is there a way to check if only alphabets (a-z) or numbers (0-9) is pressed ?

I think this should work

if ( ( e.keyCode>=Keyboard.A && e.keyCode<=Keyboard.Z ) ||
     ( e.keyCode>=Keyboard.NUMBER_0 && e.keyCode<=Keyboard.NUMBER_9 ) ||
     ( e.keyCode>=Keyboard.NUMPAD_0 && e.keyCode<=Keyboard.NUMPAD_9 )  ) {
  ...
}
0

Featured Post

Identify and Prevent Potential Cyber-threats

Become the white hat who helps safeguard our interconnected world. Transform your career future by earning your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

Question has a verified solution.

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

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Exchange administrators are always vigilant about Exchange crashes and disasters that are possible any time. It is quite essential to identify the symptoms of a possible Exchange issue and be prepared with a proper recovery plan. There are multiple…
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

830 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