while True:
    r, w, x = select([dev], [], [])
for event in dev.read():
    if event.type == ecodes.EV_KEY:
        pass
How can I capture mouseevents and keyevents using python in background on linux