Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.11 ~Solved] Check when a player press a hotkey in his inventory


Recommended Posts

Hi !

I'm still working on my Item Editor GUI mod. The mod is working well, but I need something else.

At the moment, the GUI opens when the player has an item in his mainhand and when he press the "I" hotkey.

What I also would like to do, is to detect when a player press the hotkey in his inventory while hovering an item.

The problem is, the event I use (KeyInputEvent) only fires when the player is out of a GUI (when he is "in game").

Does someone know how can I do that ?

Link to comment
Share on other sites

Thanks !

So now when I press a key the event fires, but I can't detect when my hotkey is pressed. This is what I've done :

public void onGuiKeyPressed(KeyboardInputEvent e) {
System.out.println("Key pressed in GUI");
KeyBinding[] keyBindings = ClientProxy.keyBindings; // Registered in initialisation
if (keyBindings[0].isPressed()){ // The keybinding I use
	System.out.println("Binded key pressed in GUI");

I use my


condition in my


and it works, but here it doesn't.

Link to comment
Share on other sites

  • GuiScreenEvent.KeyboardInputEvent

    is the parent event, use one of the sub-events.

  • Neither



    are the right event to check for an activated key binding. If you just want to check whether your key binding was activated using


    , use


    (note that it has two phases, choose one).

  • Key bindings do not activate in a GUI. You can manually check for the key using

    , but then you have to use the raw methods in LWJGL's


    class (




    ) to find out, whether the key was released or pressed and which key it was. You check if your key binding matches a specific key code using



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.