Why not use
keyReleased[
^]
Another option would be to use both
keyPressed
and
keyReleased
and if you have already jumped after the key has been pressed, you wouldn't jump again. In pseudo code, something like
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_SPACE && jumpOk) {
jump();
jumpOk=false;
}
}
....
<pre>@Override
public void keyReleased(KeyEvent e) {
jumpOk=true;
}
Just remember to initialize the
jumpOk
variable to true when you start this part of the program