Key response not recognizing allowed keys

Hello,
I’m having a very strange problem with the keyboard input - it will not recognize specific keypresses that I designate as “allowed keys” and will thus not end the routine and move on in the experiment. It happens for brand new psyexp files I create and old files that have run fine in the past. This is happening on both MacOS version 2024.2.1 and Windows version 2024.2.5. An older version of PsychoPy I have on my personal laptop (MacOS, v2023.2.3) is not having this problem.
If I leave “allowed keys” blank, it will work fine, so it is not a problem with general input. In trying to diagnose the problem, I turned off the allowed keys and looked at the .csv file. It appears to be storing a timestamp with the keypress, which may lead to an incorrect “match” with the allowed keys, which does not end the routine.


I can’t find anywhere in the builder that may turn off storing these timestamps, and I looked into the code to find the getKeys function, however it does not appear to have timeStamped=True. (though I am not a Python expert so I may be missing something).

I could just revert to an older version of PsychoPy, but I don’t like that as a long-term solution. Any advice here would be appreciated.
Thank you,
Lindsay

Why are you using a code component? I’m wondering how I might replicate this issue. I would put the allowed keys in the keyboard component.

Hi Wakecarter,

I’m not using a code component. If I put anything in the “allowed keys” box, the experiment freezes when I press any keys, including the keys I’ve allowed. I looked in the code to try to diagnose the problem, but I was not editing the code. My best guess is that because the resp.keys function is pulling the cumulative response time to store with the keypress, this led to a logical error such that the allowed keys were looking for [‘left’] but the key was coded as [‘left’, 17.85…]. Since those two items do not match, the routine did not end.

Perhaps my question is more that I have no idea why the resp.keys function is storing the cumulative time, as this is not what it’s done when I’ve used it in the past and I have not made any code or builder edits to update this.

I hope that clarifies things!
Lindsay

At the moment I’d recommend version 2024.1.4 for MacOS users experiencing issues. However, this isn’t an issue I’ve seen before.

Before you try another version:

  1. Try changing the input backend.
  2. Try changing the use version.

Both are in Experiment Settings