Cobiyyy Posted February 8, 2021 Posted February 8, 2021 So i used the KeyBinding class (net.minecraft.client.settings.KeyBinding) to add a new keybind but it only triggers when i am not in a gui, i am new to forge and what not so im not sure how i could fix this issue? Quote
Cobiyyy Posted February 8, 2021 Author Posted February 8, 2021 On 2/8/2021 at 6:57 PM, diesieben07 said: That is normal, key bindings are disabled in a Screen. Check out the various keyboard related events in GuiScreenEvent for detecting keyboard input while a screen is open. Note that this might not be a good idea, due to for example text input fields. Expand I see like for JEI they could type something and it would trigger what ever i am trying to do. Quote
SoLegendary Posted November 27, 2021 Posted November 27, 2021 Resurrecting this thread to ask: Is there a way to enable keybindings while in a GUI? I've been able to use GuiScreenEvent.KeyboardKeyEvent but for detecting held buttons it has a delay after the initial press, just like when holding down a button to repeat the same character while typing. The same is true for getGui().keyPressed(). However, keybindings do not have this issue and are guaranteed to execute code smoothly when a key is held. I've noticed that some GUI screens do in fact allow keybindings when open, like the player inventory screen. Is there a way to also allow use of keybindings on custom GUIs? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.