This might be the only working solution that I discovered for newer versions.
public static boolean chatOpened = false;
public static void onGUIChange(GuiOpenEvent event)
chatOpened = event.getGui() instanceof ChatScreen;
public static void onKeyInput(final InputEvent.KeyInputEvent e)
if(!chatOpened && e.getKey() == 'F')
I'm posting it so people wouldn't struggle with deprecated code from old threads like I did at first.
Yet, I'm curious; Is there a simpler one or an official way from Forge to check the chat screen in 1.17.x? Thank you