Last active
January 19, 2025 16:45
-
-
Save CRImier/27b7b61abe468f20b422a9c359361ebe to your computer and use it in GitHub Desktop.
listen-keys: shows you all input events. apt install python3-evdev .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#try this one !/usr/bin/sudo /usr/bin/python3 | |
from evdev import InputDevice, list_devices, categorize, ecodes | |
from time import sleep | |
import threading | |
def listen_for_events(dev): | |
for event in dev.read_loop(): | |
if event.type != ecodes.SYN_REPORT: # an attempt to filter out syn reports to work around a specific screwy touchpad | |
print (dev.name, ": ", str(categorize(event))) | |
devices = [InputDevice(fn) for fn in list_devices()] | |
print(devices) | |
for dev in devices: | |
print(dev.name, " - ", dev.fn) | |
thread = threading.Thread(target=listen_for_events, args=(dev,)) | |
thread.daemon = True | |
thread.start() | |
while True: | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment