Self Paced Reading Task with questions

Great @dilsah_kalay. This should solve your problem. In the code component, you create an empty list for storing your code in the Start Routine tab called rtList:

word_list = Sentence.split() 
word_list.reverse() # switch the order 
event.clearEvents()
rtList = []

Then, you need to amend the code in the Each Frame tab so that the keyboard events are timestamped, that key events are indexed correctly on every frame, and stored at the appropriate time in the rtList:

while continueRoutine:
    kb = event.getKeys(timeStamped=True)
    if len(kb) > 0:
        if 'space' in kb[0]:
            try:
                nextWord = word_list.pop()
                text.setText(nextWord)
            except IndexError:
                continueRoutine = False
                rtList.append(kb[0][1])
                break
        rtList.append(kb[0][1])
        if 'q' in kb[0]:
            core.quit()
    win.flip()

Finally, in the End Routine tab. you need to run a numpy (np) function that finds the difference between the RTs in the list, because all of the RTs in the keyboard component are stored relative to the onset of the very first presentation of a text stimuli in each trial - where a trial is a presentation of a sentence + question. Note, in this version I have inserted a fixation point at the beginning of every trial to mark the trial onset, and also a time from when to collect RTs i.e., after the first button press to remove the fixation. If this is not required, the code will need to be changed a bit. Finally, run a loop that writes the RTs to a data file, in separate columns for every word:

rtList = np.ediff1d(rtList)
for rts in range(len(rtList)):
    thisExp.addData('word_{}'.format(rts), rtList[rts])