Description
If a movement key and the Debug Modifier Key are bound to the same physical key, holding that key while an inventory screen is open keeps the player moving. Movement should be ignored whenever a screen is open, but the Debug Modifier Key is exempt from that gate, so the shared key still registers as held.
The movement is real and not visual only. The client sends the movement to the server, so the player actually walks around the world with the screen still open.
Steps to reproduce
Join a world.
Bind "Walk Forwards" and "Debug Modifier Key" to the same key.
Open an inventory screen (survival inventory, chest, etc.).
Hold that key.
The player moves while the screen stays open.
Observed behavior
The shared movement key registers and the player moves while an inventory screen is open.
Expected behavior
Movement keys are ignored while a screen is open, the same as they are when not sharing a key with the Debug Modifier Key.
Cause
In KeyboardHandler.keyPress, key bindings are normally only set when no screen is open. That guard is boolean handlesGameInput = this.minecraft.screen == null. Later the code does:
if (handlesGameInput || key == options.keyDebugModifier.key) {
...
KeyMapping.set(key, true);
KeyMapping.click(key);
}The || key == options.keyDebugModifier.key part makes the Debug Modifier Key an exception to the screen-open guard, so the pressed key still gets its binding set to down even with a screen open. KeyMapping.set flips every binding registered to that physical key, so when a movement key shares the key, the movement binding is set down too. KeyboardInput.tick then reads it as held and feeds it into player movement on the next tick. The open screen never gets to suppress the input the way it does on the normal path.
Thank you for helping us improve Minecraft! We saved your files: