I am trying to capture linux keyboard/mouse input, and I am reading events from like /dev/input/event2. But it seems the input are sometimes directed to /dev/
/dev/input/event2
/dev/
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