InputEvent (String actionName) { final Shortcut[] shortcuts = getActiveKeymapShortcuts(actionName).getShortcuts(); KeyStroke keyStroke = null; for (Shortcut each : shortcuts) { if (each instanceof KeyboardShortcut) { keyStroke = ((KeyboardShortcut)each).getFirstKeyStroke(); break; } } if (keyStroke != null) { return new KeyEvent(JOptionPane.getRootFrame(), KeyEvent.KEY_PRESSED, System.currentTimeMillis(), keyStroke.getModifiers(), keyStroke.getKeyCode(), keyStroke.getKeyChar(), KeyEvent.KEY_LOCATION_STANDARD); } else { return new MouseEvent(JOptionPane.getRootFrame(), MouseEvent.MOUSE_PRESSED, 0, 0, 0, 0, 1, false, MouseEvent.BUTTON1); } }