Example usage for javafx.scene.input KeyEvent isShiftDown

List of usage examples for javafx.scene.input KeyEvent isShiftDown

Introduction

In this page you can find the example usage for javafx.scene.input KeyEvent isShiftDown.

Prototype

public final boolean isShiftDown() 

Source Link

Document

Returns whether or not the Shift modifier is down on this event.

Usage

From source file:Main.java

private static int modifiers(final InputEvent event) {
    if (event instanceof MouseEvent) {
        final MouseEvent mouseEvent = (MouseEvent) event;
        int modifiers = 0;
        if (mouseEvent.isAltDown()) {
            modifiers |= java.awt.event.MouseEvent.ALT_MASK;
            modifiers |= java.awt.event.MouseEvent.ALT_DOWN_MASK;
        }//from   w w w .  j a v  a  2s .c  om
        if (mouseEvent.isControlDown()) {
            modifiers |= java.awt.event.MouseEvent.CTRL_MASK;
            modifiers |= java.awt.event.MouseEvent.CTRL_DOWN_MASK;
        }
        if (mouseEvent.isMetaDown()) {
            modifiers |= java.awt.event.MouseEvent.META_MASK;
            modifiers |= java.awt.event.MouseEvent.META_DOWN_MASK;
        }
        if (mouseEvent.isShiftDown()) {
            modifiers |= java.awt.event.MouseEvent.SHIFT_MASK;
            modifiers |= java.awt.event.MouseEvent.SHIFT_DOWN_MASK;
        }
        if (mouseEvent.isPrimaryButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON1_MASK;
        }
        if (mouseEvent.isMiddleButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON2_MASK;
        }
        if (mouseEvent.isSecondaryButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON3_MASK;
        }
        return modifiers;
    }

    if (event instanceof KeyEvent) {
        final KeyEvent keyEvent = (KeyEvent) event;
        int modifiers = 0;
        if (keyEvent.isAltDown()) {
            modifiers |= java.awt.event.KeyEvent.ALT_MASK;
        }
        if (keyEvent.isControlDown()) {
            modifiers |= java.awt.event.KeyEvent.CTRL_MASK;
        }
        if (keyEvent.isMetaDown()) {
            modifiers |= java.awt.event.KeyEvent.META_MASK;
        }
        if (keyEvent.isShiftDown()) {
            modifiers |= java.awt.event.KeyEvent.SHIFT_MASK;
        }
        return modifiers;
    }

    return 0;
}

From source file:nars.rl.util.ThreeDView.java

private void handleKeyboard(Scene scene, final Node root) {
    final boolean moveCamera = true;
    scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override/*from  w w  w  .j av  a2s. c  o  m*/
        public void handle(KeyEvent event) {
            Duration currentTime;
            switch (event.getCode()) {
            case Z:
                if (event.isShiftDown()) {
                    cameraXform.ry.setAngle(0.0);
                    cameraXform.rx.setAngle(0.0);
                    camera.setTranslateZ(-300.0);
                }
                cameraXform2.t.setX(0.0);
                cameraXform2.t.setY(0.0);
                break;
            case X:
                if (event.isControlDown()) {
                    if (axisGroup.isVisible()) {
                        axisGroup.setVisible(false);
                    } else {
                        axisGroup.setVisible(true);
                    }
                }
                break;
            case S:
                if (event.isControlDown()) {
                    if (space.isVisible()) {
                        space.setVisible(false);
                    } else {
                        space.setVisible(true);
                    }
                }
                break;
            case SPACE:
                if (timelinePlaying) {
                    timeline.pause();
                    timelinePlaying = false;
                } else {
                    timeline.play();
                    timelinePlaying = true;
                }
                break;
            case UP:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() - 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 10.0 * ALT_MULTIPLIER);
                } else if (event.isControlDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() - 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() - 2.0 * ALT_MULTIPLIER);
                } else if (event.isShiftDown()) {
                    double z = camera.getTranslateZ();
                    double newZ = z + 5.0 * SHIFT_MULTIPLIER;
                    camera.setTranslateZ(newZ);
                }
                break;
            case DOWN:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() + 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 10.0 * ALT_MULTIPLIER);
                } else if (event.isControlDown()) {
                    cameraXform2.t.setY(cameraXform2.t.getY() + 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.rx.setAngle(cameraXform.rx.getAngle() + 2.0 * ALT_MULTIPLIER);
                } else if (event.isShiftDown()) {
                    double z = camera.getTranslateZ();
                    double newZ = z - 5.0 * SHIFT_MULTIPLIER;
                    camera.setTranslateZ(newZ);
                }
                break;
            case RIGHT:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() + 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 10.0 * ALT_MULTIPLIER);
                } else if (event.isControlDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() + 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() - 2.0 * ALT_MULTIPLIER);
                }
                break;
            case LEFT:
                if (event.isControlDown() && event.isShiftDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() - 10.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown() && event.isShiftDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 10.0 * ALT_MULTIPLIER); // -
                } else if (event.isControlDown()) {
                    cameraXform2.t.setX(cameraXform2.t.getX() - 1.0 * CONTROL_MULTIPLIER);
                } else if (event.isAltDown()) {
                    cameraXform.ry.setAngle(cameraXform.ry.getAngle() + 2.0 * ALT_MULTIPLIER); // -
                }
                break;
            }
        }
    });
}