I’ve build an experiment which goes through many phases and loops. However, I would like to be able to press the “ESC” key at any given moment while the experiment is running in order to close the window and end the experiment.
I’m aware that I could use this chunk of code:
while True: keys = event.getKeys() if keys: if keys == 'Esc': win.close() core.quit()
However, I would have to add this bit of code it to every loop and routine, which may be problematic in some cases. What I’m looking for is an easier way to accomplish this. For example, I’m hopping for a “global option” that I can setup at the beginning of the experiment? If not, which would be the best way to proceed?
Thank you for your inputs.