Citation:
Each JComponent has one action map and three input maps. The input maps correspond to the following focus situations:
JComponent.WHEN_FOCUSED The component has the keyboard focus. The WHEN_FOCUSED input map is typically used when the component has no children. For example, buttons bind the Space key using the WHEN_FOCUSED map.
These bindings are only effective when the component has focus.
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT The component contains (or is) the component that has the focus. This input map is commonly used for a composite component — a component whose implementation depends on child components. For example, JTables make all their bindings using WHEN_ANCESTOR_OF_FOCUSED_COMPONENT so that if the user is editing, the up-arrow key (for example) still changes the selected cell.
JComponent.WHEN_IN_FOCUSED_WINDOW The component's window either has the focus or contains the component that has the focus. This input map is commonly used for mnemonics or accelerators, which need to be active regardless of where focus is in the window.