Index: trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java	(revision 7608)
+++ trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java	(revision 7609)
@@ -125,6 +125,8 @@
             } else if (set.add((e.getKeyCode())) && enabled) {
                 synchronized (this) {
-                    for (KeyPressReleaseListener q: keyListeners) {
-                        q.doKeyPressed(e);
+                    if (isFocusInMainWindow()) {
+                        for (KeyPressReleaseListener q: keyListeners) {
+                            q.doKeyPressed(e);
+                        }
                     }
                 }
@@ -135,6 +137,8 @@
                 if (set.remove(e.getKeyCode()) && enabled) {
                     synchronized (this) {
-                        for (KeyPressReleaseListener q: keyListeners) {
-                            q.doKeyReleased(e);
+                        if (isFocusInMainWindow()) {
+                            for (KeyPressReleaseListener q: keyListeners) {
+                                q.doKeyReleased(e);
+                            }
                         }
                     }
@@ -165,9 +169,5 @@
         }
 
-        // check if key press is done in main window, not in dialogs
-        Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
-        if (SwingUtilities.getWindowAncestor(focused) instanceof JFrame) {
-            processKeyEvent(ke);
-        }
+        processKeyEvent(ke);
     }
 
@@ -190,3 +190,8 @@
         this.enabled = enabled;
     }
+
+    private boolean isFocusInMainWindow() {
+        Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+        return SwingUtilities.getWindowAncestor(focused) instanceof JFrame;
+    }
 }
