python-evdev allows Python programs running in Linux to read and write input events. It provides bindings to both the generic input event interface (evdev) and the userspace input subsystem (Uinput). This will automatically build for Python 3 if it's available.