keyboard icon indicating copy to clipboard operation
keyboard copied to clipboard

Is it possible to detect a keypress of a specific keyboard?

Open bertoost opened this issue 3 years ago • 2 comments

I have connected a 3rd keyboard to my macbook and I want to detect a keypress from the specific keyboard, not from the others. Is that possible at all?

Regards, Bert

bertoost avatar May 23 '22 14:05 bertoost

on linux we have a device identification :

def on_pressed_keys(e):
    print(e.to_json())
    print(keyboard._pressed_events)

    if e.device == '/dev/input/event4':
      # you are on your device

keyboard.hook(on_pressed_keys)
# Block forever, like `while True`.
keyboard.wait()

fpiccinali avatar Jul 25 '22 15:07 fpiccinali

I am working on a macbook :-)

bertoost avatar Jul 25 '22 18:07 bertoost