Pressing the tab-key exits experiments

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): macOS 10.14.6
PsychoPy version (e.g. 1.84.x): 3.2.3
Standard Standalone? (y/n) If not then what?: Yes
*What are you trying to achieve?: I did per accident realise in an experiment that pressing the tab-key on the keyboard exits the experiment as it also happens when pressing the escape-key. I was able to replicate this in other experiments (e.g. the Demo-experiments). As I’m creating an experiment using keyboard inputs I’m somewhat afraid that participants might accidentally exit the experiment by pressing the tab-key. Therefore I would like to turn that “feature” off.

What did you try to make it work?:
When turning off “enable escape key” the tab-key exits the experiment no longer. I know that it would be possible to insert a code snippet to assign e new key combination for exiting the experiment, but I was wondering if it would also be possible just to turn off the tab-key.

Hi @Michael92, for Macs it looks like the escape key has been mapped onto the tab key for the new keyboard. This means that if “Enable escape key” is selected, pressing the tab key will always quit the experiment because it is called “escape”. There are two ways to solve this problem:

  • Disable escape key to quit task. Then add the code below in a code component to “Each Frame” tab - this is your quit code that ignores tab but responds to the actual escape key.
  • Reverting back to the old style, but slower, keyboard. Do this by going to Experiment Settings and setting the version of PsychoPy to anything lower than 3.1.

Quit code

if key_resp.status == STARTED:  # assuming keyboard is called "key_resp"
    theseKeys = key_resp.getKeys(keyList=['escape'], waitRelease=False)
    if len(theseKeys):
        theseKeys = theseKeys[0]  # at least one key was pressed
            
        # check for quit:
        if 41 == theseKeys.code:  # 41 is Escape key code. 43 is tab key code
            endExpNow = True

By the way, I have put in a request to have this changed on Github