Originally posted March 20th, 2019.

Background
In an earlier post we used a MilliKey response box to test the time stamping accuracy of three different Python accessible keyboard event APIs when receiving 1000 Hz MilliKey USB keyboard events:
- psychopy.event.getKeys()
- psychopy.iohub…keyboard.getPresses()
- Psychtoolbox Python PsychHID()
and found that Psychtoolbox PsychHID Python interface provided the most accurate keyboard event time stamps across all three OS’es tested, particularly for macOS.
PsychoPy3 keyboard.Keyboard
In this post we use the MilliKey response box to test the latest development version of PsychoPy3 and the new keyboard event handling module added by Jon Pierce, psychopy.hardware.keyboard.Keyboard.
psychopy.hardware. keyboard.Keyboard uses the Psychtoolbox PsychHID Python interface to provide accurate cross platform 1000 Hz keyboard event time stamping.
Results
psychopy.hardware. keyboard.Keyboard
PsychoPy3’s psychopy.hardware. keyboard.Keyboard module takes full advantage of the PsychHID engine to provide accurate 1000 Hz MilliKey keyboard event time stamping on Windows, Linux, and macOS. Average event latency is ~1 msec across all operating systems.

Very nice.
Comparision
In comparison, lets look at the performance of other PsychoPy keyboard event APIs.
psychopy.iohub..keyboard.getPresses()
Python3 psychopy.iohub keyboard event timing is not as consistent across operating systems. On Windows, and in particular Linux, iohub comes close to matching the performance of PsychHID, but macOS causes extra delay compared to other operating systems.

psychopy.event.getKeys()
Results for psychopy.event.getKeys() are similarly poor across operating systems. Remember that in this test keyboard events were being created during calls to win.flip(). The timing results show how big of an impact this has on time stamping error when a 60Hz monitor is used.

Happy Hacking!