3 Replies Latest reply on Aug 1, 2006 2:30 PM by Newsgroup_User

    Making use of the Key.ALT isDown

    VoxEcho
      I need to make a keyhandler which will respond to the alt key being pressed, but all i get is the menu. in my experience most prgrams do not activate the menu's unless the altkey is released with no other action, OR if alt+? is selected.

      So, i am hoping that there is a way to make it so that alt+arrow_key can be targeted... anyone?

      -E
        • 1. Re: Making use of the Key.ALT isDown
          Level 7
          VoxEcho,

          > I need to make a keyhandler which will respond to the
          > alt key being pressed, but all i get is the menu.

          What menu are you talking about? Are you in the IDE? Are you testing
          in a web page? In a Projector?

          > in my experience most prgrams do not activate the menu's
          > unless the altkey is released with no other action, OR if alt+?
          > is selected.

          On WinXP Home, I see the file menu take focus in Flash, Photoshop, and
          Word when I hit Alt by itself. Maybe I don't understand what you're asking?

          > So, i am hoping that there is a way to make it so that
          > alt+arrow_key can be targeted... anyone?

          Your subject line kind of points in the right direction. :) Look up
          the Key class in the ActionScript 2.0 Language Reference; specifically, the
          Key.isDown() method -- you'll see some sample code. Note: this is for
          *most* cases. For better or worse, though, Alt is the odd one out. Alt
          does not trigger the Key.onKeyDown or Key.onKeyUp event.

          You have to constantly check for the Alt key in a loop of some kind,
          such as setInterval() or MovieClip.onEnterFrame ...

          this.onEnterFrame = function() {
          if (Key.isDown(18)) {
          trace("Alt is being pressed!");
          }
          };

          ... and you have to know that the key code for Alt is 18. A big difficult,
          because that number is mysteriously missing from the Keyboard Keys and Key
          Code Values entry of the documentation.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Making use of the Key.ALT isDown
            VoxEcho Level 1
            well, i am using isDown(Key.ALT) and that's not working. will try isDown(18)

            ....

            nope that didn't do it. even if another key is pressed (say, the down arrow) it will not do anything if the alt was pressed down first UNLESS control is pressed down TOO :\

            i am sure there is more to it then that, but that is what i have so far :\

            thanks for your help
            • 3. Re: Making use of the Key.ALT isDown
              Level 7
              VoxEcho,

              > well, i am using isDown(Key.ALT) and that's not
              > working. will try isDown(18)

              Right. :) There is no Key.ALT constant. I can see why you tried it,
              but it's not a feature of ActionScript.

              > ....
              > nope that didn't do it. even if another key is pressed
              > (say, the down arrow) it will not do anything if the alt
              > was pressed down first UNLESS control is pressed
              > down TOO :\

              Will you show your code? My proof of concept worked for me, when I
              tested before replying.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."