1 Reply Latest reply on Sep 10, 2009 7:35 AM by kglad

    Key Press are getting buffered.

    randhir_thakur

      I am trying to scroll a list of some 100 items. I am using onKeyDown to detect the arrow keys and scroll the list. The problem is that if I keep the key key pressed for some time and then release it, the scrolling doesnot stop immediately. It seems like the key press is buffered and scrolling stops when all the key presses have been executed. I tried to set a flag in onKeyDown and reset it after the function is executed. But that also doesnot help. Can anyone help me?

       

      var keyListener:Object = new Object();

      keyListener.onKeyDown = function() {
          bKeyIsPressed =true;
          }
          var keyPressed:Number = Key.getCode();
             switch (keyPressed) {
                case (Key.DOWN) :
                   pressDown();
                   break;
                case (Key.UP) :
                  pressUp();
                   break;
               
             }
          bKeyIsPressed = false;
      };

       



      Key.addListener(keyListener);

        • 1. Re: Key Press are getting buffered.
          kglad Adobe Community Professional & MVP

          i don't see that problem but you can assign a variable to pressDown and null it when you no longer want pressDown()'s code to execute:

           

          a=pressDown;

           

          a(); // in your key listener

           

          a=null; when you want pressDown code to stop being called

           

          a=pressDown;  when you want to re-enable your key listener's down actions.

          1 person found this helpful