TLDR; Keyboard input locks while playing Minecraft and other times but is most noticeable when using WASD movement keys in game. Changed from Ubuntu to Fedora, removed USB hub from connection chain, changed keybaords. Issue still persists. XEV output provided. I don't know where else to look to pinpoint the cause of the issue.
The more detailed version:
I've noticed an issue with keyboard input while playing Minecraft Java edition in Linux. I'm looking to be pointed in a direction to find the root cause. I don't know where else to look besides changing my from X11 to Wayland. I'll try that when I get a chance and update this post. While playing the game the key I'm pressing will get "stuck" down and will not release. This is software only as the keyboard keys are not physically stuck down. The mouse continues to work correctly. The only keyboard input that I've managed to get to work is CTRL+ALT+F(n) to switch to another console. If I switch back nothing responds to key presses until the issue passes. I've tried other keyboards and plugged the keyboard directly into the PC front USB ports to eliminate the USB hub and switchers. I even moved the USB switcher to a different rear USB port. I thought that helped but the issue still occurs. It is randomly occurring but seems to occur more often and for longer periods of time if the Minecraft window is full screen.
This issue occurs with Ubuntu 22.04 (X11) and Fedora 39 (X11). Both are using current offered version of Gnome with all available updates installed. Hardware: Dell Precision 3650 Intel i7-11700K 32GB DDR4 EVGA GeForce GTX 970 OC
Current environment: Fedora Linux 39 (Workstation Edition) Linux 6.6.6-200fc39.x86_64 Gnome 45.2 X11
Keyboard: E-Element Z-88 USB keyboard and Motospeed K-82 USB keyboard Mouse: Logitech G502 and Anker Optical Vertical Mouse USB chain: Anker A7515 USB hub > Sabrent USB-SW30 USB switcher -> rear USB port on PC, or keyboard and mouse directly to front USB ports.
These are the changes I've attempted while troubleshooting: Moving USB ports directly connecting to PC vs going through USB hub and switcher full screen vs windowed Ubuntu vs Fedora
I learned of the Xev utility to monitor keyboard and mouse so I ran that utility with the Minecraft game window selected. This is where I found the first bit of info that might come in handy for troubleshooting. I'm not familiar with the output and what it means. The issue just happened while typing this message in Firefox. My keyboard input stopped working in the text input box. I could use the mouse to highlight and select text. I could select other windows with the mouse and type there. I could press the Super key to bring open Activities. Then I noticed my typing was slowly showing up in the text box if I selected it and waited. It was almost like using a very poor dialup connection for a remote terminal back in the 90s; just waiting for my typing to catch up. It took more than 2 minutes for 5 words, a handful of gibberish, and some backspacing to finish showing up. I still can't type in the text input box in Firefox but I was able to select what I had written with the mouse and middle-click to paste it into Text Editor to finish typing.
I haven't tried Wayland yet to determine if the issue is specific to X11.
I will attach a text file of output from the xev utility but below is an example of normal input and what is repeated continuously while the issue is occurring. In the normal output the pressed key is correctly shown in the state line. While the issue occurs, a keys matrix is shown repeatedly with the key I'm pressing being represented in the various locations in the matrix. Apparently 'w' (bound to move forward in Minecraft) is represented by a '32' in Col 5 of Row 1. This changes depending on keypresses but nothing responds in-game or anywhere else until the issue ceases and I can ALT-TAB out of the game or press ESC to release the mouse from the game window.
Normal Xev output from keyboard input in Minecraft:
KeyRelease event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12770871, (2305,800), root:(2305,1054),
state 0x10, keycode 39 (keysym 0x73, s), same_screen YES,
XLookupString gives 1 bytes: (73) "s"
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12771159, (2373,791), root:(2373,1045),
state 0x10, keycode 25 (keysym 0x77, w), same_screen YES,
XLookupString gives 1 bytes: (77) "w"
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12771159, (2373,791), root:(2373,1045),
state 0x10, keycode 25 (keysym 0x77, w), same_screen YES,
XLookupString gives 1 bytes: (77) "w"
XmbLookupString gives 1 bytes: (77) "w"
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12771207, (2373,791), root:(2373,1045),
state 0x10, keycode 25 (keysym 0x77, w), same_screen YES,
XLookupString gives 1 bytes: (77) "w"
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12772551, (2409,793), root:(2409,1047),
state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12772551, (2409,793), root:(2409,1047),
state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12772623, (2409,793), root:(2409,1047),
state 0x14, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (01) ""
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12772623, (2409,793), root:(2409,1047),
state 0x14, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (01) ""
XmbLookupString gives 1 bytes: (01) ""
XFilterEvent returns: False
Xev output when the issue begins (I'm guessing the key 32 is 'w'):
KeyPress event, serial 30, synthetic NO, window 0x4c0000b,
root 0x1ef, subw 0x0, time 12717159, (31,636), root:(31,890),
state 0x14, keycode 25 (keysym 0x77, w), same_screen YES,
XLookupString gives 1 bytes: (17) ""
XmbLookupString gives 1 bytes: (17) ""
XFilterEvent returns: False
FocusOut event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyGrab, detail NotifyNonlinear
FocusIn event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyUngrab, detail NotifyNonlinear
KeymapNotify event, serial 30, synthetic NO, window 0x0,
keys: 4294967279 0 0 2 32 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyGrab, detail NotifyNonlinear
FocusIn event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyUngrab, detail NotifyNonlinear
KeymapNotify event, serial 30, synthetic NO, window 0x0,
keys: 4294967279 0 0 2 32 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyGrab, detail NotifyNonlinear
FocusIn event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyUngrab, detail NotifyNonlinear
KeymapNotify event, serial 30, synthetic NO, window 0x0,
keys: 2 0 0 2 32 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FocusOut event, serial 30, synthetic NO, window 0x4c0000b,
mode NotifyGrab, detail NotifyNonlinear