void (Robot robot, KeyStroke keyStroke) { assert !SwingUtilities.isEventDispatchThread() : "Robot playback must not be in EDT"; boolean shift = (keyStroke.getModifiers() & InputEvent.SHIFT_MASK) > 0; boolean alt = (keyStroke.getModifiers() & InputEvent.ALT_MASK) > 0; boolean control = (keyStroke.getModifiers() & InputEvent.CTRL_MASK) > 0; boolean meta = (keyStroke.getModifiers() & InputEvent.META_MASK) > 0; if (shift) { robot.keyPress(KeyEvent.VK_SHIFT); } else { robot.keyRelease(KeyEvent.VK_SHIFT); } if (control) { robot.keyPress(KeyEvent.VK_CONTROL); } else { robot.keyRelease(KeyEvent.VK_CONTROL); } if (alt) { robot.keyPress(KeyEvent.VK_ALT); } else { robot.keyRelease(KeyEvent.VK_ALT); } if (meta) { robot.keyPress(KeyEvent.VK_META); } else if (metaKeyPresent) { try { robot.keyRelease(KeyEvent.VK_META); } catch (IllegalArgumentException e) { LOG.warn(e); //noinspection AssignmentToStaticFieldFromInstanceMethod metaKeyPresent = false; } } if (keyStroke.getKeyCode() > 0) { robot.keyPress(keyStroke.getKeyCode()); robot.delay(Registry.intValue("actionSystem.playback.delay")); robot.keyRelease(keyStroke.getKeyCode()); } else { robot.keyPress(keyStroke.getKeyChar()); robot.delay(Registry.intValue("actionSystem.playback.delay")); robot.keyRelease(keyStroke.getKeyChar()); } if (shift) { robot.keyRelease(KeyEvent.VK_SHIFT); } if (control) { robot.keyRelease(KeyEvent.VK_CONTROL); } if (alt) { robot.keyRelease(KeyEvent.VK_ALT); } if (meta) { robot.keyRelease(KeyEvent.VK_META); } }