Java Code Examples for javafx.scene.input.KeyCode#equals()

The following examples show how to use javafx.scene.input.KeyCode#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyPress.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean isDoublePress(KeyCode matchingKeyCode, KeyCode currentKeyCode) {
    long keyEventTime = System.currentTimeMillis();
    if ((keyEventTime - lastKeyEventTime) < keyPressSpeed
            && currentKeyCode.equals(lastKeyPressedCode)
            && currentKeyCode.equals(matchingKeyCode)) {
        lastKeyPressedCode = null;
        lastKeyEventTime = 0;
        return true;
    } else {
        lastKeyPressedCode = currentKeyCode;
        lastKeyEventTime = keyEventTime;
    }
    return false;
}
 
Example 2
Source File: KeyPress.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean isValidKeyCombination(KeyCode firstKeyPressed, KeyCode keyPressed) {
    long keyEventTime = System.currentTimeMillis();
    if ((keyEventTime - lastKeyEventTime) < keyPressSpeed && firstKeyPressed.equals(lastKeyPressedCode)) {
        lastKeyPressedCode = null;
        lastKeyEventTime = 0;
        return true;
    } else {
        lastKeyPressedCode = keyPressed;
        lastKeyEventTime = keyEventTime;
    }
    return false;
}