psychopy.org | Reference | Downloads | Github

While loop: response is not registered during first loop?

Dear,

I programmed an experiment in which participants need to typ three-letter words that are briefly presented on the monitor. There are 25 trials (one word per trial). However, during the first loop, the typed answer (‘response’ in the code) is not registered. It is only registered as from the second iteration.

while trial_index<25:
#Fixation dot
        gaze_dot = visual.Circle(window, units='pix', radius=10, lineColor='red', fillColor='red')
        gaze_dot.draw()
        window.flip()
        user_input.wait_spacebar_input(on_escape=exit_experiment
 # Get the next word
        word = words_to_test[word_index]
        gaze_dot.draw()
#Display word on the monitor
        render125.render_word_uni_left( window, word, black)
#Type
        response=event.getKeys(keyList=None, modifiers=False, timeStamped=False)
#Add responses to results with some other trial characteristics
        results.append((PP, variant, exp, word, str(response)))
        trial_index += 1
        word_index += 1

This is what gets written to my csv-file:

PP1,FULL REPORT,UNIFORM_2,scd,[]
PP1,FULL REPORT,UNIFORM_2,dnl, [‘s’, ‘c’, ‘d’]
PP1,FULL REPORT,UNIFORM_2,hol,[‘d’, ‘n’, ‘l’]
PP1,FULL REPORT,UNIFORM_2,efh,[‘h’, ‘o’, ‘l’]

During the first trial ‘scd’ is shown, but the answer is only appended when ‘dnl’ is shown.
Any idea how to fix this?

Best,
Koen