void (@NotNull JComponent component, @NotNull ActionListener action, @NotNull ShortcutSet shortcuts) { for (Shortcut shortcut : shortcuts.getShortcuts()) { if (shortcut instanceof KeyboardShortcut ks) { KeyStroke first = ks.getFirstKeyStroke(); KeyStroke second = ks.getSecondKeyStroke(); if (second == null) { component.registerKeyboardAction(action, first, JComponent.WHEN_IN_FOCUSED_WINDOW); } } } }