Hi,
I have a fairly complex experiment code I am running in matlab in conjunction with psychtoolbox. To cut a long story short the script runs a number of trials in for-loops split into 4 separate runs e.g.:
Open onscreen window ..BLAH BLAH.. for i=1:12; % scripts [onsetTimesTot(i,:), responsesTot(i,:), kpTot(i,:)] = presentStory(i, screenparms, … expinfo, scriptID ,script, scriptCond, imcell, handle, subject); end
Basically I am trying to figure out a way of including a piece of code that will exit the script (and close the open window) if a person presses the esc key at any point during the experiment. Sounds simple but I just cannot get anything I try to work…. The suggestions online are to spam ctrl+c then type sca and press enter which is very unreliable and doesn't work half the time!
Does anybody know an easy bit of code I could add in to do this?
Thanks in advance and sorry for the rookie question!
Best Answer