I think there might be a way to do this using Python-evdev if your platform and use-case are within its limits. Here is pressing usb dell keyboard ‘a’ then ‘1’ followed by laptop built-in keyboard ‘a’ then ‘1’
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096721.375626, code 04, type 04, val 458792
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096721.375626, code 28, type 01, val 00
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096721.375626, code 00, type 00, val 00
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.583632, code 04, type 04, val 458756
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.583632, code 30, type 01, val 01
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.583632, code 00, type 00, val 00
adevice /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.647657, code 04, type 04, val 458756
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.647657, code 30, type 01, val 00
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.647657, code 04, type 04, val 458782
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.647657, code 02, type 01, val 01
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.647657, code 00, type 00, val 00
1device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.743662, code 04, type 04, val 458782
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.743662, code 02, type 01, val 00
device /dev/input/event12, name "Dell Dell USB Keyboard", phys "usb-0000:03:00.3-1.1.3/input0", uniq "" event at 1729096727.743662, code 00, type 00, val 00
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.111097, code 04, type 04, val 30
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.111097, code 30, type 01, val 01
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.111097, code 00, type 00, val 00
adevice /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.178102, code 04, type 04, val 30
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.178102, code 30, type 01, val 00
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.178102, code 00, type 00, val 00
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.202795, code 04, type 04, val 02
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.202795, code 02, type 01, val 01
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.202795, code 00, type 00, val 00
1device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.299206, code 04, type 04, val 02
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.299206, code 02, type 01, val 00
device /dev/input/event0, name "AT Translated Set 2 keyboard", phys "isa0060/serio0/input0", uniq "" event at 1729096730.299206, code 00, type 00, val 00
You can see the ‘a’ and ‘1’ at the beginning of corresponding ‘device’ lines. The point is that the input keys are stamped with keyboard of origin. I don’t have time to work on this now, but it looks promising. The trick for you is to carefully figure out who (I mean which keyboard) is allowed to type at what time and how to buffer if you are going to want more than 1 keystroke logged. I have no idea how this will interact with psychopy either.