Constantly listen for a key 't' throughout the experiment

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2021.1.2
Standard Standalone? (y/n) If not then what?: yes

What are you trying to achieve?:
I am developing a task that needs to listen for a ‘t’ signal from a pulse generator throughout the whole experiment. Originally I tried copying a code component per frame to every single routine that will save data once a ‘t’ is sent from the pulse generator.

However, we have been running into problems using the pulse generator to start the experiment (so we have to press the keyboard but ideally the pulse generator should start it). Once the experiment is started, the per frame code component has been saving the data correctly in the data file.

I was wondering is there a better way to implement this?

Any advise will be appreciated.


I do not think there’s a better way than using code components and having code that listens for t in the Each frame tab. You could of course use keyboard components as well, but it is basically the same.

I might be misunderstanding, but if you just want to block the experiment until you get a t I have a suggestion. Insert a routine at the beginning of the experiment with an endless keyboard component that forces routine to end on t.