title: how to get onKeyPressed Duration?
body: <p>I am trying to create a snake game where i use arrow keys or WASD to move the snake.
  Initially the snake is slow and moves at 2 fps speed (like the classic snake game), i want the snake to move faster when i am holding down one of the keys and set it to original speed when i release it. </p>
  
  <p>i tried changing the movement rate inside onKeyPressed like so:</p>
  
  <pre><code>scene.setOnKeyPressed(event -&gt; {input = event.getCode().toString();
              for (String acceptedKey : acceptedKeys) {
                  if (event.getCode().toString().contains(acceptedKey)) {
                      movement.setRate(4);
                      break;
                  }
              }
          });
  </code></pre>
  
  <p>Then changing it to normal rate when i released it:</p>
  
  <pre><code>scene.setOnKeyReleased(event -&gt; movement.setRate(1));
  </code></pre>
  
  <p>*movement is a Timeline which starts since the beginning of game till stopped or death of snake.</p>
  
  <p>The code works as i intended But every time i hit a key it speeds up for a cycle and then slows down.
  I want the speed to change only when i hold a key for a certain duration (say 400 milliseconds) so is there a way i can put an if statement that checks duration of onKeypressed()?</p>