Whenever I am using an X11 session or a XWayland window, there is a chance the keyboard will stop working (globally for X11, only in XWayland windows if session is Wayland) until the session is restarted.
Nothing gets written in any log, the keyboard just stops getting registered in X11/Xwayland contexts. It will happen usually after heavy operations of the keyboard (like holding a shift key, or multiple buttons get pressed repeatedly or too quickly). It happens almost every time I play videogames, and happened only once during normal typing.
Attaching an external keyboard doesn't matter, as it will have the same synthoms.
I am using a ASUS VivoBook Pro 15 N580VD laptop. Running Debian 12 and KDE Plasma. This is not a faulty keyboard, as doesn't happen on Windows and in strict Wayland contexts.
EXTRA info:
I want to further add that the only keyboard that remains working in a full X11 environment is the Super key, that in KDE Plasma opens the application list (like Microsoft Windows).
If it is known, here is a not full list of applications I was using when this was happening and what are they based on:
Minecraft, Project Zomboid (Java GLFW)
League of Legends, Palworld (Windows applications under Wine/Proton)
Victoria 3, Crusader Kings 3 (Native Vulkan applications under, X11, they use XWayland on Wayland contexts)
Way back at the dawn of time, there was a regular issue with low quality applications that would run XGrabKeyboard() (or XGrabPointer()), and then get stuck without releasing it again. If you can, try to log in over the network from another machine and kill application processes one by one until it releases? It's most likely the video game (or library used by it) that has gotten stuck.
Are you sure its a similar issue? Because usually closing the window actually doesn't solve it, as then reopening another X11/XWayland window will still not register keyboard presses. I am adding some more info to the post right now.
I’m not sure, there can always be other issues. But note that closing the window is not the same as terminating the application. When you close the window, the application gets a signal that it usually handles as cleaning up and shutting down. But if it is hanging, that task is not performed and resources are still held.