Mojira Archive
MC-1519

Key gets stuck when toggling fullscreen

When pressing down a key (i.e. "W") and pressing F11 to toggle fullscreen at the same time will cause the action that key handles to continue, when the key is released.

I expected the action (moving forward) to stop as I released the key.

What that actually happened was that the action (moving forward) kept on until I pressed another key.

Steps to Reproduce:
1. Press and hold down a key that performs a moving action. Do not release it.
2. Press F11
3. Release F11
4. Release the key you pressed in (1.).
5. Watch. The movement will not stop.
6. Press and release another key on your keyboard.
7. The action stops.

Code analysis

Based on 1.11 decompiled using MCP 9.35 rc1 and https://github.com/LWJGL/lwjgl on 14. December 2016

When fullscreen mode is toggled the following methods are called in this order:

  1. org.lwjgl.opengl.Display.setFullscreen(boolean)
  2. org.lwjgl.opengl.Display.destroyWindow()
  3. org.lwjgl.input.Keyboard.destroy()
  4. org.lwjgl.input.Keyboard.reset()

And org.lwjgl.input.Keyboard.reset() resets the pressed keys. Therefor the keyboard never registers that the keys which were previously pressed are unpressed now.
This can be solved in Minecraft by calling the method net.minecraft.client.settings.KeyBinding.unPressAllKeys() before returning from the method net.minecraft.client.Minecraft.toggleFullscreen().