2

I use the key LEFT and RIGHT to move the position of my view. When I press and hold down the key the view moves to the side, pauses a short time, and then keeps moving until I release the key. Is it possible to skip the pause between the first action and the actions afterwards?

gridPane.setOnKeyPressed(
    e -> {
        e.consume();
        if (e.getCode() == KeyCode.RIGHT)
        {
            moveMarkerNextPositionWithKeys(e.isAltDown());
        }
        else if (e.getCode() == KeyCode.LEFT)
        {
            moveMarkerPreviousPositionWithKeys(e.isAltDown());
        }
    }
);
user1803551
  • 12,965
  • 5
  • 47
  • 74
Yupp
  • 315
  • 3
  • 18
  • 1
    Possible duplicate of [Delay between pressing a key and the key being read as held down](https://stackoverflow.com/questions/24211266/delay-between-pressing-a-key-and-the-key-being-read-as-held-down) – user1803551 Sep 10 '18 at 14:48

1 Answers1

4

The pause you are referring to is the keyboard repeat delay which can be set in the OS. E.g on windows Control panel->Keyboard->Speed->Repeat delay. It cannot be overridden. You need to implement a timer which starts with a keypressed event and moves your view until a keyreleased event.

bakcsa83
  • 405
  • 1
  • 7
  • 20