python evdev or how to read usb keyboard input in python
from evdev import InputDevice, categorize, ecodes
def ky(num):
keys = {
71: "7",
72: "8",
73: "9",
75: "4",
76: "5",
77: "6",
79: "1",
80: "2",
81: "3",
82: "0",
96: "enter"
}
return keys.get(num)
device = InputDevice("/dev/input/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.1:1.0-event-kbd") # my keyboard
for event in device.read_loop():
if event.type == ecodes.EV_KEY:
if (event.value == 1):
print(ky(event.code))
all you need is to find right path for your InputDevice