-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyListener.java
More file actions
39 lines (32 loc) · 879 Bytes
/
KeyListener.java
File metadata and controls
39 lines (32 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Jade;
import static org.lwjgl.glfw.GLFW.GLFW_PRESS;
import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
public class KeyListener
{
private static KeyListener instance;
private boolean keyPressed[] = new boolean[350];
private KeyListener() {}
public static KeyListener get()
{
if (KeyListener.instance == null)
{
KeyListener.instance = new KeyListener();
}
return KeyListener.instance;
}
public static void keyCallback(long window, int key, int scancode, int action, int mods)
{
if (action == GLFW_PRESS)
{
get().keyPressed[key] = true;
}
else if (action == GLFW_RELEASE)
{
get().keyPressed[key] = false;
}
}
public static boolean isKeyPressed(int keyCode)
{
return get().keyPressed[keyCode];
}
}