Example usage for javafx.scene.input KeyCodeCombination getShift

List of usage examples for javafx.scene.input KeyCodeCombination getShift

Introduction

In this page you can find the example usage for javafx.scene.input KeyCodeCombination getShift.

Prototype

public final ModifierValue getShift() 

Source Link

Document

The state of the shift key in this key combination.

Usage

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  w  w  .  j ava  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 w w . j a v  a2 s. com*/
 */
@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;
}