6 Replies Latest reply on May 4, 2010 4:50 PM by Flex harUI

    Catching multiple keystrokes?

    iamcootis Level 1

      I have a function that tries to catch multiple key strokes...

       

      For example, I want to be able to press Alt + 1 and be able to send "hi" to a textInput. I found the code on how to do this on the Adobe site, but it doens't work correctly 100% of the time. Sometimes it will display "hi", other times it will display "1".

       

      private function keyHandler(event:KeyboardEvent):void {
                      var bShiftPressed:Boolean = event.shiftKey;
                      var bAltPressed:Boolean = event.altKey;
                      if (bAltPressed) {
                          switch(event.keyCode){
                              case Keyboard.NUMBER_1:
                                  btnClick('hi');
                              break;
                          }
                      }

       

      Does anyone have any idea on how to make this work?