0 Replies Latest reply on Sep 19, 2006 4:14 AM by Schmurfy

    intercept tab key press

    Schmurfy
      Hi,
      For my application I need to use a textarea as a code editor but my problem is that tabulation key is used to give the focus to the next control but I want the tab key to simply insert a tabulation.
      Here is my current state:
      I have this in my textarea definition:

      keyDown="onKeyDown(event)"

      and in a script block:

      private function onKeyDown(event:KeyboardEvent):void
      {
      if( event.keyCode == Keyboard.TAB ){
      ta.text+= "\t";
      }
      }

      When I hit the tab key a tabulation is added as planned but the focus go to the next control, I tried "event.preventDefault()" and "event.stopPropagation()" but both failed, the focus still manage to leaves the control. I also tried to change all my controls focusEnabled properties to false but now the problem is that the event is not event fired when pressing tab, it is fired however when I press alt+tab...

      I hope someone has a magical solution since I have no ideas left :/