1 Reply Latest reply on Jun 12, 2006 10:30 PM by Craig Grummitt

    'Delete' KeyListener

    babo_ya Level 3
      Hi,
      I have this function to add the 'delete key pressed' event.
      But, the problem is that I have about 30 text input fields and when I press the delete key to delete a character in one of these input fields it triggers this function.

      So, What I need is that somehow disable the this delete key event when pressed inside of a text input field.

      Thanks for your help.

      function deleteKeyFunction():Void
      {
      var keyListener:Object = new Object();
      keyListener.onKeyDown = function() {
      if (Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE))
      {
      _root.deleteKeyPress();
      }

      };
      Key.addListener(keyListener);
      }
        • 1. Re: 'Delete' KeyListener
          Craig Grummitt Level 3
          Replace your fifth line of code with the following:

          if ((Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE)) && eval(Selection.getFocus()).type <> "input")

          This looks at the current selection - Selection.getFocus() - and checks that it isn't an input text field.