Key press not working on MacOS

OS (e.g. Win10): MacOS Monterey
PsychoPy version (e.g. 1.84.x): v2022.2.2
Standard Standalone? (y/n) yes

I was trying to build my first Builder program. I followed a video on youtube to build a Stroop task. The issue was that PsychoPy Builder did not seem to pick up key press events and the program never stopped (so I had to force quit). I changed my Security & Privacy setting, allowing PsychoPy to have access to Input Monitoring and Accessibility, but the problem still persisted.

Using Coder, however, the simple demo of key response, Demos > input >, worked in my case. This helped me to find out that keyboard would work as long as KB backend (kb.getBackend()) was ‘ptb’, instead of ‘iohub’.

Then, in Builder, the solution is to click “Edit experiment settings”, go to ‘Input’ tab, and change ‘Keyboard Backend’ from ‘iohub’ to ‘ptb’. This is easy, but not very intuitive for someone who use Builder for the first time.

Also as I read the code generated by Builder, the routineTimer, which was a core.Clock() object, used methods like addTime(), which I believed to be no longer available in the latest version of PsychoPy (so it’s fine if I run the generated script with the standard standalone, but it doesn’t work if I want to run the script in a python environment). I wonder if the addTime method is the best way to ensure that timing is accurate, and if there is an alternative function that I should use if I would like to do some programming with the latest version.

If you are using a Mac then you may need to authorise PsychoPy to monitor your input.

  1. Go to System Preferences (easiest way is to press Cmd+space together, and type System Preferences)
  2. Go to Security & Privacy (top row, the house symbol).
  3. Go to Privacy (top right) and unlock.
  4. Go to Input Monitoring (left hand side)
  5. Add a tick next to PsychoPy
  6. Click Save and Reopen. PsychoPy will need restart.