psychopy.org | Reference | Downloads | Github

When i use wait.keys in a block,it needs to press the keyboard twice to move on

for trial in Trials:
stim.setColor(trial[‘color’])
stim.setPos([trial[‘position’],0])

#fixation
selfx.draw()
win.flip()
core.wait(inf_time[‘cueTime’])
#stimulation
stim.draw()
win.flip()
respClock.reset()
core.wait(inf_time[‘stimTime’])
#clear screen
win.flip()
#wait for responses
keys = event.waitKeys(keyList = [‘left’,‘right’])
resp = keys[0]
rt=respClock.getTime()
if resp=='left’and trial[‘color’]==‘red’:
correct=1
elif resp=='right’and trial[‘color’]==‘green’:
correct=1
else: correct=0
win.flip()

Please follow this guideline:

Also please try to write a full question rather than just paste in a section of code. Don’t assume that what you can squeeze in the title of your post will be enough to tell people the relevant context and issue. Help us to help you.