title: Applet Java 7 update 21: Cannot set AWTKeyListener on default Toolkit
body: <p>In my self-signed applet (that may possibly become a CA-signed applet in near future) in which I have a fairly complex Swing GUI, I need to detect whenever the user has the SHIFT- or CONTROL-key pressed. I am using this in combination with component-related MouseEvents and MouseMotionEvents to do special mouse-event processing at any time. Shortly: </p>
  
  <p>When I recieve a mouse-motion-event on a distinct component I need to detect whether CONTROL or SHIFT is being held down (pressed). The problem is, that a user will press down shift/control BEFORE he/she moves the mouse into the component of interest. This is my real "usability" problem!</p>
  
  <p>Prior to Java 7 update 21 I was able to accomplish that using a JVM-global AWTKeyListener which I added to the default Toolkit. This is no longer allowed (due to security requirements of Java 7 update 21 - and this in despite of, that I am JNLP-launching my applet in a distinct and separate JVM, but that's another talk).</p>
  
  <p>So what do I have:</p>
  
  <p>I have tried to register a KeyListener with the "main" panel of my applet, but key-events seem to be "swallowed" (by whatever component in my GUI which is having the keyboad focus).</p>
  
  <p>Then I have tried using key-bindings for my main-panel (the top-level container), adding bindings for "shift", "control" and "escape". The only binding working is for "escape", and it always hits my "released" action. "Shift" and "control" are never hit (notified). I am using the WHEN_IN_FOCUSED_WINDOW input-map of my main-panel.</p>
  
  <p>I need to detect keyboard events application-wide (and NOT JVM-wide). How can I accomplish that?
  Is it possible to "intercept" keyboard-events at some level in my component-hierarchy by other means?</p>
  
  <p>I don't mind overriding Swing/AWT methods in order to accomplish it - I am just desparete to find a solution.</p>
  
  <p>I appreciate any suggestions, as I will otherwise discourage customers from updating Java to 7 upd 21. Thanks!</p>
  
  <p>Aron</p>
  
  <p>PS: Why is there no support for "application"-global resources in Java. It goes for Authenticators, Keylisteners, Default Locale etc..? It is always on a JVM-global basis, despite we (as applet developers) only need it at application level.</p>