How to open and close a GUI with the same keybind?

Started by Bulb on

Topic category: Help with modding (Java Edition)

Last seen on 15:22, 28. Sep 2024
Joined Sep 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to open and close a GUI with the same keybind?
Sat, 09/28/2024 - 15:04 (edited)

So, how to make a keybind, which can open and close the same GUI. You open it, for example with "K", and close it with "K", not only ESC button. 
My MCreator version is 2024.1 , I'm making a mod for Java Minecraft 1.20.1 Forge.
The only thing I want is a Java code for opening GUI with the same keybind with commentaries or a MCreator procedure screenshot. 
Thank you in advance, sincerely!

Edited by Bulb on Sat, 09/28/2024 - 15:04
Last seen on 16:25, 28. Sep 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if have gui open, closeif…
Sat, 09/28/2024 - 16:26

if have gui open, close
if not have gui open, open it