Assuming that you've built your experiment using code, the strategy would be to use event.waitKeys()
as you do now, but then only have visual action when a certain key is pressed and add other keys to a list. So if your target key is space:
from psychopy import visual, event
win = visual.Window()
for trial in range(5): # loop over trials. Usually a list of dicts.
# Prepare and present your stimuli here.
# Then enter a response-listening phase:
allResponses = [] # we will fill this in with responses
while True:
response = event.waitKeys() # you probably have event.waitKeys(keyList=['space']) or something like that right now
allResponses += response # add keynames. Adds nothing on empty response
if 'space' in response:
break # break out of the while-loop
# Save trial here along with the contents of allResponses
If you're actively transitioning the content on the screen, you would do this in a for-loop with a call to win.flip()
on every iteration rather than the while-loop above. This will discretize the times that you can record responses by the frame rate (usually 60 times per second). If you need finer resolution for e.g. reaction times, use the iohob background where keys are recorded as a separate process, independent on the presentation of stimuli.