Linux keyboard event capturing /dev/inputX
Hello,
I was recently trying to accomplish something similar.
Have a look at the logkeys project:
http://code.google.com/p/logkeys/
If you download the source code, and have a look at the logkeys.cc file, you will find one method how to auto-detect which /dev/input/event is used by your keyboard. This will let you read raw scan codes from the keyboard, regardless of which program currently has focus. The logkeys program also shows how to translate the scan codes into characters, and other useful tricks.
Hope this helps,
Markus.
A simple grep
operation on the /proc/bus/input/devices file will yield all the keyboards plugged into the machine:
grep -E 'Handlers|EV=' /proc/bus/input/devices | \
grep -B1 'EV=120013' | \
grep -Eo 'event[0-9]+'
Where EV=120013
is the bitmask for events supported by the device. As explained here.
This is the way it is implemented in logkeys
You are reading the wrong device. Either try all /dev/input/event* or look in /var/log/Xorg.0.log for which device is used for your keyboard.