Open LukeShortCloud opened 2 years ago
For direct access to input devices, a user must either be (1) the root
user or (2) a user in the input
group.
All of the definitions for codes and their related physical keys on a keyboard can be found here: /usr/include/linux/input-event-codes.h
.
This is useful for creating programs that involve using an input device (such as an infrared receiver, keyboard, etc.).
/dev/input/<EVENT_DEVICE>
returns four values: (1) the type, (2) the code, (3) seconds, and (4) microseconds. The most important part is the code value as that is the key/button that was pressed.https://stackoverflow.com/questions/5060710/format-of-dev-input-event
To find the input device, view this directory:
For example,
/dev/input/by-id/usb-Apple__Inc_Apple_Keyboard-event-kbd
may show up as a human-friendly symlink to/dev/input/event24
. The symlink or the actual event file can be used with the above Python code.