I would like to allow the participant to quit the experiment any time when the “Esc” key is pressed and also to give the feedback as “incorrect” answer, and move to the next trial if the participant takes more than 1700 msec to answer a trial. Please, which code should I insert inside the loop?
Thanks in advance
# Loop TRAINING for trial_, trial in enumerate(trials): if trial_ == 24: break # Present fixmark imgfix.draw() fixonset = disp.flip () wait (FIXTIME) # Draw the fixation mark and the cues imgfix.draw() cuestim[trial["cueside"]].draw() cueonset = disp.flip() wait (CUETIME) # Draw the fixation mark imgfix.draw() # Update the monitor cueoffset = disp.flip() #wait for the SOA minus the cue duration wait (trial["soa"] - CUETIME) # Draw the fixation mark imgfix.draw() # Draw a target stimullus tarstim[trial ["tarside"]].draw() # Update the monitor taronset = disp.flip() # Wait for a response resplist = waitKeys (maxWait=float("inf"), keyList = ["left", "right"],timeStamped = True) # Select the first response from the response list response, presstime = resplist # Calculate de RT RT = presstime - taronset # Check if the response was correct if response == tarstim [trial ["tarside"]].correctAns: correct = 1 else: correct = 0 # Valid cue? if [trial ["cueside"]] == [trial ["tarside"]]: validity = 1 else: validity = 0 # Show feedback fbstim[correct].draw() disp.flip() wait (FEEDBACKTIME)