4 Replies Latest reply on Aug 31, 2011 4:27 AM by flexx0r

    ALT Key Pressed Event


      Good Day,


      Trying to set up a system to use 'Alt-A' as a keyboard shortcut.  I have added the Event listener, and I have all the keycodes working as they should - with the CTRL key.  If I try and use the ALT key for the combination, I get no where.  The event listener doesn't fire on an ALT Key keyDown/keyUp.


      How can I enable the ALT key to work?  I mean the keyboard Event has an ALTKey result, just like CTRLKey, but unlike the CTRLKey, ALTKEY does nothing.


      Clients want ALTKey to be used.







        • 1. Re: ALT Key Pressed Event

          I am seeing the same problem - when pressing ALT-<key> the keyHandler function is not called.  Here is the code:


          <?xml version="1.0"?>

          <!-- events/TrapAllKeys.mxml -->

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"




                      private function initApp():void {

                          application.addEventListener(KeyboardEvent.KEY_UP, keyHandler);



                      private function keyHandler(event:KeyboardEvent):void {

                          t1.text = event.keyCode + "/" + event.charCode;





              <mx:TextInput id="myTextInput"/>


              <mx:Text id="t1"/>



          copied from:



          I am in the process of porting an existing java  applet to flex and we want to preserve the existing shortcut keys used for buttons as part of a general effort to meet section 508 guidelines.


          I have tried several browsers - Chrome, Firefox, IE, running on Windows XP,  FlashPlayer 10.1.n, all with the same results.


          Is there anything that can be done get the ALT-<key> event?



          • 2. Re: ALT Key Pressed Event
            rob_parkhill Level 1

            I have tried for a few months to get the AltKey event to fire.  There is a

            event.altKey portion of the keyup/down event, but it never registers, and

            from my investigations, pressing the Alt key actually stops ALL other

            keyboard events from firing.  i.e. pressing ALT-C doesn't fire the listener

            whereas just C or CTRL-C does.


            I came to the conclusion that the event.altKey result was only applicable to

            AIR applications, and migrated all controls to use CTRL, made for some

            unhappy users for a short period of time.



            • 3. Re: ALT Key Pressed Event
              iamcootis Level 1

              Depending on what OS you're using, the Alt key can get captured by the OS and never make it to your FLEX application. I don't have my old project in front of me at the moment, but I think I fixed it by doing a combination of 'ctrl + alt + A.' If this doesn't work send me a PM and I'll look at one of my older project when I'm at my computer.

              • 4. Re: ALT Key Pressed Event
                flexx0r Level 1

                Hi tried what you said:


                else if((event.ctrlKey)||(event.altKey)||(event.keyCode == 65))
                                    trace('ALT Key pressed!');


                but the alt key event will not be fired.


                My project is even an air application and the OS is windows.


                Does anyone figure out what to do?


                Greetings from germany