Jump to content

Key Events while inventory open


Recommended Posts



I'm trying to get the CraftingKeys mod working in combination with a eye tracking keyboard to make crafting more accessible to people unable to use a keyboard/mouse. One classic problem with alternative keyboard inputs is that they tend to give instantaneous key press events, rather than slow finger presses - this means that you almost never detect the key events when polling isKeyDown().


What's the best approach to detecting key events while the inventory is open? The mod's onKeyInput() method only gets called in-game (not when the inventory is open). I've tried iterating over the whole event queue, which does successfully find the events I care about, but it also consumes any other events, so that other keys don't work (such as pressing Esc to close the inventory).


Is there some way I can subscribe to key events within the vanilla inventory GUI? Or should I be re-publishing events that I consume but don't care about? The latter seems a bit low-level to me.


Any pointers would be greatly appreciated,



Link to comment
Share on other sites

If the mod is polling isKeyDown they need to fix that, there is no way around it.


The proper way is to get notified by keyboard events by checking Keyboard.getEventKey / getEventKeyState in KeyInputEvent (outside GUIs) and/or GuiScreenEvent.KeyboardInputEvent (same thing, but when a GUI is open).

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.