List of usage examples for javafx.scene.input KeyCodeCombination getShortcut
public final ModifierValue getShortcut()
From source file:com.ubershy.streamsis.actions.HotkeyAction.java
/** * Presses the provided {@link KeyCodeCombination}'s keys. * * @param kb the KeyCodeCombination * @return true, if successful/*from w ww . j a va 2 s.co m*/ */ @SuppressWarnings("deprecation") protected boolean keysDown(KeyCodeCombination kb) { try { if (kb.getShortcut() == ModifierValue.DOWN) { robot.keyPress(shortcutKeyEvent); Thread.sleep(modifiersPressSleepTime); } if (kb.getAlt() == ModifierValue.DOWN) { robot.keyPress(KeyEvent.VK_ALT); Thread.sleep(modifiersPressSleepTime); } if (kb.getShift() == ModifierValue.DOWN) { robot.keyPress(KeyEvent.VK_SHIFT); Thread.sleep(modifiersPressSleepTime); } // I know this is a bad practice. Do you have any idea how to avoid this, stranger? robot.keyPress(kb.getCode().impl_getCode()); Thread.sleep(modifiersPressSleepTime); } catch (InterruptedException e) { logger.debug("Haha, not this time, InterruptedException!"); return false; } return true; }
From source file:com.ubershy.streamsis.actions.HotkeyAction.java
/** * Releases the provided {@link KeyCodeCombination}'s keys. * * @param kb the KeyCodeCombination * @return true, if successful/*from w ww . j a va 2 s .c o m*/ */ @SuppressWarnings("deprecation") protected boolean keysUp(KeyCodeCombination kb) { try { // I know this is a bad practice. Do you have any idea how to avoid this, stranger? robot.keyRelease(kb.getCode().impl_getCode()); Thread.sleep(modifiersPressSleepTime); if (kb.getShift() == ModifierValue.DOWN) { robot.keyRelease(KeyEvent.VK_SHIFT); Thread.sleep(modifiersPressSleepTime); } if (kb.getAlt() == ModifierValue.DOWN) { robot.keyRelease(KeyEvent.VK_ALT); Thread.sleep(modifiersPressSleepTime); } if (kb.getShortcut() == ModifierValue.DOWN) { robot.keyRelease(shortcutKeyEvent); } } catch (InterruptedException e) { logger.debug("Haha, not this time, InterruptedException!"); return false; } return true; }