psychopy.org | Reference | Downloads | Github

event.getKeys issues

I am writing a bit of code (Win-10 PC, PsychoPy-3 with visual.MovieStim3) to show videos as follows:

  • Introduction page (From here to Video page by pressing space bar)
  • Show videos (From here to Thank you page automatically)
  • Thank you page (Wish to exit/end experiment by space bar but it is not working)

Here is my code semantic:

imports are here…

--------------- Introduction page ----------------------------------

introText = ‘Hi I will show you some movies’
textStims = visual.TextStim(win=win, name=‘textStims’,
text= introText,
font=‘Arial’,
wrapWidth=None, ori=0,
color=‘white’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=0.0);

textStims.Pos = (0, 0)
textStims.height = 0.10
continueRoutine = True
while continueRoutine:
textStims.setAutoDraw(True)
win.flip()
if event.getKeys(keyList=[“space”]):
textStims.setAutoDraw(False)
win.flip(clearBuffer=True)
continueRoutine = False
if event.getKeys(keyList=[“escape”]):
win.close()
core.quit()

------------ Show videos here ---------------------------

------------ Videos end ---------------------------

--------------- Thank you page ----------------------------------

endText = ‘Many thanks!’
textStims = visual.TextStim(win=win, name=‘textStims’,
text= endText,
font=‘Arial’,
wrapWidth=None, ori=0,
color=‘white’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=0.0);

textStims.Pos = (0, 0)
textStims.height = 0.10

continueRoutine = True
while continueRoutine:
textStims.setAutoDraw(True)
win.flip()
if event.getKeys(keyList=[“space”]):
textStims.setAutoDraw(False)
win.flip(clearBuffer=True)
continueRoutine = False

win.close()
core.quit()

My Quetion is why I can’t Finish/Exit my experiment after showing the “----Thank you Page----”
PsychoPy simply not allowing me to exit pressing “space” bar!
(Kindly Note: I can do the job another way but interested to know why this is not working)
Any idea would be highly appreciated.

Thank you

White space is very important when reading Python code, so:

In addition to the feedback Michael has provided, can you please provide all of the source code?