1 Reply Latest reply on Aug 26, 2009 10:33 AM by Joe ... Ward

    Ctrl-v key combo not working in keydown event in Adobe Air

    sergemeunier Level 1

      I am needing to capture the ctrl-c/ctrl-x/ctrl-v keys in the keydown Javascript event from within Adobe Air.


      I have managed to get the events to fire correctly.


      When I press ctrl, c, x, v, ctrl-c and ctrl-x, I get the correct corresponding keycodes. However, when I press ctrl-v, no event gets triggered.


      Is Air preventing the key presses from reaching this event in the case of ctrl-v?


      Here is the code I am using:

          document.getElementById('main_grid').addEventListener('keydown', keyDownEvent, false);


          keyDownEvent = function(e) {

        • 1. Re: Ctrl-v key combo not working in keydown event in Adobe Air
          Joe ... Ward Level 4

          I'm surprised you get ctrl-c and ctrl-x. Do they work when you have selected text? What is probably happening is the default handler for the paste event is "swallowing" the keystroke. You could try listening for the paste event and calling the event object's preventDefault() method. (I haven't tried it, though, so I'm not positive that would allow the keystroke to be passed along.) If you are trying to create your own copy/paste functions, you might be better off listening for the copy and paste events themselves, rather than the raw keystrokes.


          Another alternative is to listen for the keystrokes on window.htmlLoader, which should get the keystrokes before they are passed to the HTML engine.