1

I've used the keyboard module in python to identify a keypress event as shown below.

import keyboard

while True:
    if keyboard.read_key() == "k":
        print("You pressed k")
        break

Now I have 2 keyboards and I want to identify the keyboard used to press the key (Something like below).

import keyboard

while True:
    if 'k' of keyboard 1 pressed:
        print("You pressed k of keyboard 1")
        break
    if 'k' of keyboard 2 is pressed:
        print("You pressed k of keyboard 2")
        break

Can I do this with the keyboard module? If not is there any other way to do this in python?

KavG
  • 169
  • 1
  • 12
  • The short answer is no, keyboard library cannot identify which keyboard sent the keypress. There is no easy way to do this from Python, and you would have to delve into OS-specific low-level APIs to determine that information. – m1el Sep 27 '21 at 17:02

0 Answers0