On Linux when using X11/Xorg, when you use xinput
to disable they keyboard (e.g. xinput set-prop $ID "Device Enabled" 0
) the 'key-up' event is not send (because you've disabled the keyboard). This is noticable if you enter that command on the command line, it'll act like you're holding 'enter' down. This is because the command (which disables the keyboard) runs before you lift your finger off the enter key.
This is discussed in this bug ( https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-input-evdev/+bug/724280 ) and this blog post ( http://blog.yjl.im/2010/12/using-xinput-to-disable-keyboard-mouse.html ).
I am writing a programme that needs to disable the keyboard, and want to avoid this problem. Is there any way/command to "release all the keys that are currently pressed" (which could be run just after the "disable the keyboard" command)? Or is there a command/way to "get a list of all the current keys that are pressed" and a way to manually/programmatically send the "key released" event? (This way I could disable the keyboard, see what keys are pressed, and then 'release' those keys).
Is this possible?
"I am writing a programme that needs to disable they keyboard, and want to avoid this problem"
What's wrong with grabbing the keyboard focus and discarding all input?
xinput
is a pretty blunt instrument and you're hitting a bug that's more than two years old which means it isn't likely to get fixed. Indeed, the bug is probably far older than that, and could be considered "expected behavior" by someone making use of it.