void (@NotNull JComponent component, int mnemonic) { InputMap map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); int mask = getFocusAcceleratorKeyMask(); if (component instanceof AbstractButton) { map.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "pressed"); map.put(KeyStroke.getKeyStroke(mnemonic, mask, true), "released"); map.put(KeyStroke.getKeyStroke(mnemonic, 0, true), "released"); } else if (component instanceof JLabel) { map.put(KeyStroke.getKeyStroke(mnemonic, mask, true), "released"); } else if (component instanceof ActionButtonComponent) { map.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "doClick"); } }