LWJGL - Continuous key press event without delay
- by Zarkopafilis
I am checking for key presses and then based on the keys pressed I am moving a square around the screen. I am setting booleans for the keys WASD. But , Whenever I try to keep the key down , it takes a while till it moves continuously (Just a half second stop after a single move.) Any way to get rid of that and make it be "smooth"?
Code:
up = false;
down = false;
left = false;
right = false;
reset = false;
while(Keyboard.next()){
if (Keyboard.getEventKeyState()) {
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)){
reset = false;
}
if(Keyboard.isKeyDown(Keyboard.KEY_W)){
up = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_S)){
down = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_A)){
left = true;
}
if(Keyboard.isKeyDown(Keyboard.KEY_D)){
right = true;
}
}
}