How do I write in a function to close the screen if a certain button is pressed? PTB
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Timing and presenting 2D and 3D stimuli dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!