2 Replies Latest reply on Feb 5, 2016 1:41 PM by Silver Back Gorilla

    Global keyboard event listener?

    Silver Back Gorilla Level 1

      Is it possible to create a global keyboard event listener that is not tied to a window, button, or any other UI element?  The best I've been able to come up with is adding the event listener to the window.  This only works if the window is active.  If the user clicks outside of the window then the keyboard listener does not work.  Also, when the dialog first appears, this won't work until after the user has made some type of interaction with the window.  What I want is to have some keyboard shortcuts for the user that work regardless of where they have clicked on the screen, even if the dialog window is not "active".  Is this possible?


      Here is the code I am using for the keyboard listener for the window.


      mywindow.addEventListener ("keydown", function (k) {keyListen(k)});
      function keyListen(k){if(k.keyName=="Z"){alert("Do stuff here");}}