Example #1
0
  private void configureRight() {
    scene.addEventHandler(
        KeyEvent.KEY_PRESSED,
        (key) -> {
          if (key.getCode() == KeyCode.D) {
            keys.setRight();
          }
        });

    scene.addEventHandler(
        KeyEvent.KEY_RELEASED,
        (key) -> {
          if (key.getCode() == KeyCode.D) {
            keys.releaseRight();
          }
        });
  }
Example #2
0
  private void configureForward() {
    scene.addEventHandler(
        KeyEvent.KEY_PRESSED,
        (key) -> {
          if (key.getCode() == KeyCode.W) {
            keys.setSlowForward();
          }
        });

    scene.addEventHandler(
        KeyEvent.KEY_RELEASED,
        (key) -> {
          if (key.getCode() == KeyCode.W) {
            keys.releaseSlowForward();
          }
        });
  }