You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an issue with evdev in my application, which stopped working as expected. The problem is that evdev is not capturing LEFTSHIFT key presses correctly. Adding a small delay after the press and release of the LEFTSHIFT key resolves the issue. Below is a minimal example that reproduces the problem:
# This code does not work as expected. It emits a lowercase 'a', whereas it should emit an uppercase 'A'.fromevdevimportUInput, InputDevice, ecodesaseimporttimekeybd='/dev/input/event18'ui=UInput.from_device(keybd, name='keyboard-device')
ui.capabilities(verbose=True).keys()
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1) # KEY_LEFTSHIFT downui.syn()
ui.write(e.EV_KEY, e.KEY_A, 1) # KEY_A downui.write(e.EV_KEY, e.KEY_A, 0) # KEY_A upui.syn()
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 0) # KEY_LEFTSHIFT upui.syn()
ui.close()
Adding small delays after the LEFTSHIFT press and release fixes the issue:
# This code works as expected. It emits an uppercase 'A'.fromevdevimportUInput, InputDevice, ecodesaseimporttimekeybd='/dev/input/event18'ui=UInput.from_device(keybd, name='keyboard-device')
ui.capabilities(verbose=True).keys()
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 1) # KEY_LEFTSHIFT downtime.sleep(0.05) # <-- FIXES THE PROBLEMui.syn()
ui.write(e.EV_KEY, e.KEY_A, 1) # KEY_A downui.write(e.EV_KEY, e.KEY_A, 0) # KEY_A upui.syn()
ui.write(e.EV_KEY, e.KEY_LEFTSHIFT, 0) # KEY_LEFTSHIFT uptime.sleep(0.05) # <-- FIXES THE PROBLEMui.syn()
ui.close()
This behavior suggests that evdev may require a brief period to correctly register the LEFTSHIFT key state change, which is not documented or expected. Has anyone else experienced this issue, or is there a known workaround or fix?
I've encountered an issue with evdev in my application, which stopped working as expected. The problem is that evdev is not capturing LEFTSHIFT key presses correctly. Adding a small delay after the press and release of the LEFTSHIFT key resolves the issue. Below is a minimal example that reproduces the problem:
Adding small delays after the LEFTSHIFT press and release fixes the issue:
This behavior suggests that evdev may require a brief period to correctly register the LEFTSHIFT key state change, which is not documented or expected. Has anyone else experienced this issue, or is there a known workaround or fix?
Specifications of my machine
OS: Arch Linux x86_64
Host: XPS 17 9720
Kernel: 6.7.5-arch1-1
Uptime: 3 hours, 47 mins
Packages: 1369 (pacman)
Shell: zsh 5.9
Resolution: 1920x1200, 1920x1080
WM: dwm
Theme: Raleigh [GTK2/3]
Icons: Adwaita [GTK2/3]
Terminal: tmux
CPU: 12th Gen Intel i7-12700H (20) @ 4.600GHz
GPU: Intel Alder Lake-P GT2 [Iris Xe Graphics]
GPU: NVIDIA GeForce RTX 3050 Mobile
Memory: 10185MiB / 15678MiB
The text was updated successfully, but these errors were encountered: