For an eye tracking experiment i want to implement a way to close the window after the user presses the escape or q button. Eventually I want the keys to also stop the Gaze recording and save the eye-tracking data to a .cvs file. As of now the window closes after a few seconds without any input.
Simple function calls like e.g.
if keys in ["p"]: print("hello")
are also not working
I’m new to PsychoPy so any help would be appreciated!
This is my code implementation as of now
import pickle import pandas as pd from psychopy import core, event, misc, visual, monitors, data, gui from titta import Titta, helpers_tobii as helpers MY_MONITOR = 'testMonitor' # needs to exists in PsychoPy monitor center FULLSCREEN = True SCREEN_RES = [1920, 1080] SCREEN_WIDTH = 52.7 # cm VIEWING_DIST = 70 # distance from eye to center of screen (cm) monitor_refresh_rate = 60 # frames per second (fps) mon = monitors.Monitor(MY_MONITOR) # Defined in defaults file mon.setWidth(SCREEN_WIDTH) # Width of screen (cm) mon.setDistance(VIEWING_DIST) # Distance eye / monitor (cm) mon.setSizePix(SCREEN_RES) win = visual.Window(monitor=mon, fullscr=FULLSCREEN, screen=1, size=SCREEN_RES, units='deg') for keys in event.getKeys(): if keys in ["escape", "q"]: print(keys) win.close()