From b98c012c29fa7b1b327afd28b670177259e2498a Mon Sep 17 00:00:00 2001 From: Boulay Mathias Date: Mon, 31 Oct 2022 19:51:28 +0100 Subject: [PATCH] Fix: Add a check to the index This fixes some mods like galacticraft trying to get unexisting keyboard keys --- jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java index e384244c5..e389f0285 100644 --- a/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java +++ b/jre_lwjgl3glfw/src/main/java/org/lwjgl/input/Keyboard.java @@ -393,9 +393,10 @@ public class Keyboard { * @return true if the key is down according to the last poll() */ public static boolean isKeyDown(int key) { - if (!created) - throw new IllegalStateException("Keyboard must be created before you can query key state"); - return keyDownBuffer.get(key) != 0; + if (!created) + throw new IllegalStateException("Keyboard must be created before you can query key state"); + if(key >= KEYBOARD_SIZE) return false; + return keyDownBuffer.get(key) != 0; } /**