List of usage examples for javafx.scene.input KeyCodeCombination getCode
public final KeyCode getCode()
From source file:com.ubershy.streamsis.actions.HotkeyAction.java
/** * Releases the provided {@link KeyCodeCombination}'s keys. * * @param kb the KeyCodeCombination * @return true, if successful//ww w . 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; }
From source file:com.ubershy.streamsis.actions.HotkeyAction.java
/** * Presses the provided {@link KeyCodeCombination}'s keys. * * @param kb the KeyCodeCombination * @return true, if successful/* w ww . java 2 s . c om*/ */ @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; }