How can I add a keybinding that uses Control + another key?

Started by Kleiders on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I add a keybinding that uses Control + another key?

How can I add a keybinding that uses Control + another key?

I want to add that when you press Control + B, you summon a mob. How can I add this key combination as the default keybinding? I surely need custom code for that, but how do I do it?

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
no custom code, I think…
Thu, 11/04/2021 - 05:13

no custom code, I think. Just make 2 Keybindings and set a global variable of Player Persistent that when you click Ctr it sets it to true and when you Press B if it's true

do whatever

or edit the code but I would have to look through that tomorrow

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Cntr*
Thu, 11/04/2021 - 05:13

Cntr*

Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That would make it a bit too…
Thu, 11/04/2021 - 05:18

That would make it a bit too incovenient for the player if they want to change the keybinding, that's why I was looking for custom code for this :c

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yep, I will look through the…
Thu, 11/04/2021 - 05:20

Yep, I will look through the code tommorrow as it's late for me now. also I meant Ctrl, not Cntr or smt

Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Cool, thank you so much for…
Thu, 11/04/2021 - 05:22

Cool, thank you so much for your help! Let me know if you figure it out!

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
okay from the research I…
Thu, 11/04/2021 - 17:00

okay from the research I have done (I have not tested it, so you will have to figure it out), I got this piece of code:

        if ((InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_B)))

but for it to work you need to import an extra thing on the keybinds code.

import net.minecraft.client.utils.InputMappings;

I suppose you can try to add this somewhere the Keybinds code, basically this will check if Key: B is pressed

I do not promise this will work tho, haven't tested it

but why Ctrl + b? can't it be B alone? ppl are most likely to change it anyways

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(also this can't be changed…
Thu, 11/04/2021 - 17:01

(also this can't be changed unless you give a config file ppl can edit)