MaLiLib (Forge)

MaLiLib (Forge)

291k Downloads

Keybindings don't work when input method switch

stdcall0 opened this issue · 4 comments

commented

When I use any fabric mod that uses malilib as its keybinding lib (e.g MiniHUD, tweakeroo), I find that any hotkeys don't work after I switch my typing methods, even if I don't type anything, but all other functions could run normally. And hotkeys are usable again after I alt+tab to another window and alt+tab back.

I'm using Windows 10, with a Chinese input method and an US-English keyboard installed.

How to reproduce:

Set your windows 10 language to English.
Install a Chinese (or Japanese) input method
Get minecraft 1.14 with Malilib and MiniHUD.
Switch input method by pressing Win+Space in game, and try evoking the main menu of MiniHUD by pressing H+C.

sorry for my poor English!

commented

In the debug mode, after I switch the input method, 'pressing keys C (67), held keys SUPER + H + C' show in action bar while pressing H+C. Is 'SUPER' is regarded as pressed, from that debug text?

commented

(Copied from maruohon/litematica#110 (comment) as it's more relevant here):

It would seem so, yes. Can you get the SUPER key to release by just pressing it manually once? (I assume SUPER here means the windows key?)

How does one change input methods even, does it involve a key combination with the super key? Then it's likely it's getting stuck because of that. I think it's also possible to get Alt stuck by using Alt + Tab to switch windows. The problem then is, I believe, that the LWJGL library misses the key release event, so when the game and the mod query the state of the key, LWJGL still reports it as being pressed. In such a case there isn't anything I could do in the mod to fix this, if the input handling library still reports the key as being pressed.

However a part of the problem is that most of my "toggle type" keybinds in the mods are by default set to be "strict", meaning that they won't allow any extra keys to be pressed. This option can be changed by the user for affected keybinds, if needed, using the Advanced Keybind Options widget next to the hotkey button. But in general it would be better/easier to just get the keys that get stuck to be un-stuck.

In this case if it's just the super key getting stuck, then just manually pressing it once after switching the input method should be easy enough to do? Alternatively, if you are not using the super key for any hotkeys in the mods, then you can also add it to the ignoredKeys "hotkey" in malilib configs. That way malilib will completely ignore that key. I've had to do that for my MOUSE4 (forward) key, since for some odd reason when I sneak (= hold shift) and use the MOUSE3 (back) key (which is my Discord Toggle Mute), then somehow the MOUSE4 key would get pressed and get stuck on according to LWJGL and thus also malilib.

commented

Yes, that really works. Thanks for supporting! You are the best developer I've seen ^_^

commented

Why not just disable the super key by default in the windows environment? Obviously, almost no one binds this key directly in the game in the Windows system.
As far as I know, it’s not just the Asian language switching input method, as long as the game loses focus, it will cause this key stuck problem. But after disabling the super key, no matter how I switch windows or input methods, it can be used normally.
But this can simply solve the button failure caused by the game losing focus.