Python Forum
Differntiating two keyboards using evdev
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Differntiating two keyboards using evdev
#1
Hi!

For an internship I am making a wall off keyboards.
When a key is pressed on a keyboard, I need to know which one on which keyboard.
I have two keyboards on one raspberry pi.

Anyone has an idea how I can know this in my python code?

Thanks!
Reply
#2
You need to de able to read the scan code. It's been a long time, but I believe there is a device id embedded with the scan socde
for info on package see: https://pypi.python.org/pypi/keyboard/
for info on device id see: https://github.com/boppreh/keyboard/issues/21
Reply
#3
(Mar-07-2018, 04:37 PM)Larz60+ Wrote: You need to de able to read the scan code. It's been a long time, but I believe there is a device id embedded with the scan socde
for info on package see: https://pypi.python.org/pypi/keyboard/
for info on device id see: https://github.com/boppreh/keyboard/issues/21

Thanks for the reply! I imported keyboard but I don't seem to find any possible way to find the device id.
I looked at the provided link but this seems to be for windows or something?
Reply
#4
see: https://unix.stackexchange.com/questions...ress-a-key
Found with an amazing tool named google!
Reply
#5
Hi guys!

I am wondering if anyone is able to use evdev to read the input of keyboards.

Example:
"A" is pressed on keyboard 1 => I get a print that says that key a is pressed on keyboard 1
and the same for any key on both keyboards.

Essentialy I need to differentiate which keyboard is being pressed.

from evdev import InputDevice, categorize, ecodes

device = InputDevice("/dev/input/by-id/usb-Logitech_Gaming_Keyboard_G810_078936$
for event in device.read_loop():
    if event.type == ecodes.EV_KEY:
        print(categorize(event))
With this I am able to view everything from one keyboard, but not from the other. The other one has the same name but a different ID in the name.
Reply
#6
http://python-evdev.readthedocs.io/en/la...ing-select
there are several ways shown to listen to multiple devices, starting from section in link above

Also using keyboard module suggested by Larz you should be able to differentiate between different devices under Linux
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using evdev for background script hotcocoa 1 1,306 Jun-19-2022, 10:41 PM
Last Post: hotcocoa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020