Skip to content

Instantly share code, notes, and snippets.

@fladd
Created December 2, 2020 12:57
Show Gist options
  • Save fladd/6e0c0af517b961c75c721b57fc66fab1 to your computer and use it in GitHub Desktop.
Save fladd/6e0c0af517b961c75c721b57fc66fab1 to your computer and use it in GitHub Desktop.

Sorry I misunderstood before.

What you want to achieve is possible in two ways.

  1. Within Expyriment, by manually defining how to process control keys (e.g. ESC) in all wait functions you use:
def custom_process_control_keys():
    expyriment.io.Keyboard.process_control_keys(quit_confirmed_function=convert_variables)

# and then calling this explicitely as callback function in EVERY wait method in your code, e.g.:
exp.keyboard.wait(callback_function=custom_process_control_keys, process_control_events=False)
  1. Independent of Expyriment, by registering an atexit function:
import atexit
atexit.register(convert_variables)

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment