evdev (short for 'event device') is a generic input event interface in the Linux kernel and FreeBSD.
You can use blocking and nonblocking reads, also select() on the /dev/input/eventX devices, and you'll always get a whole number of input events on a read. Their layout is: struct input_event { struct timeval time; unsigned short type; unsigned short code; unsigned int value; };
Just stumbled across this -- rather late in the day.
You can find out the names and other attributes of different devices using:
cat /proc/bus/input/devices
Using sudo evtest
is very helpful.
It will list all your input devices by name and corresponding event number. Then you can enter device event number of your interest and monitor its events.
To find out, go to /dev/input/by-id
or /dev/input/by-path
and do a
ls -l
to find out which symlink points to which event<*>
.
Also, I thought it would be helpful for all those who come across this page to find this helpful link to some code which captures keyboard events.
Run this in Terminal, it will work just fine:
cat /proc/bus/input/devices | awk '/keyboard/{for(a=0;a>=0;a++){getline;{if(/kbd/==1){ print
$NF;exit 0;}}}}'
Source
I know it's a little late to reply but I hope this is helpful for friends.
“mice” contains mouse input data, but to find the file related to the keyboards we need to check the files in folder “by-path”, keyboards file names end with “event-kbd”. We need to find the links to the keyboards, and then we can find the keyboards event file. The following commands can do this automatically for us:
kbdEvents=($(ls /dev/input/by-path | grep "event-kbd"))
for forCounter in "${kbdEvents[@]}"
do
eventFile=$(readlink --canonicalize "/dev/input/by-path/${forCounter}")
# do anything ...
done
This code is part of the code for the break time on my personal website : mazKnez.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With