Hey,
to start with lwjgl i render a simple square on the screen witch should be moved by WASD. This is working fine but when i stop pressing the key the square stops moving immediately and then moves again for a second or something (depends on how long i pressed the key) and stops moving after that again. This delay is generated by my extended GLFWKeyCallback class, when I print the action variable of the invoke methode i get somethink like this:
2
2
2
2
0 <-- this is the point I stopped pressing the key
1
2 <-- but it behaves as if the key would still be pressed
2
2
2
2
2
0 <-- until it realizes again that i stopped pressing the button
I don't know if this is a bug or just a fault by me but it is quite annoying.
This is the simple input class I am using like you find it in every tutorial:
package input;
import static org.lwjgl.glfw.GLFW.*;
import org.lwjgl.glfw.GLFWKeyCallback;
public class Input extends GLFWKeyCallback {
private static boolean[] keys = new boolean[600];
@Override
public void invoke(long window, int key, int scancode, int action, int mods) {
keys[key] = action != GLFW_RELEASE;
System.out.println(action);
}
public static boolean isKeyDown(int key) {
return keys[key];
}
}