I’m using PsychoPy v1.84.2 Coder (on a 64-bit Windows 7 PC) to co-ordinate I/O events in an instrumental learning experiment. Since it is unnecessary to present stimuli, I don’t need to create a window, and I’m using Coder’s output window to display messages when a response occurs or a reinforcement is delivered. At the start of the experiment, the user has to make a couple of choices and so I’m wanting the program to detect key presses at this time. However, event.getKeys does not seem to detect any key presses unless a window has been created first. The following code works (i.e. a key press is detected, causing the program to end):
from psychopy import event, visual, core win = visual.Window() while True: if event.getKeys(): print "event" break
However, if the second line (win = visual.Window()) is removed, key presses are not detected and the program never ends. Is there some way around this?