Await user key pressing

Hi Dara,

The keyboard class doesn’t yet contain a “waitKeys method” (see this post Equivalent of event.waitKeys() using keyboard.KeyBoard). So you still need to use event.waitKeys() to wait for a keyboard response.

This should achieve what you want:


from psychopy import visual, event, core
from psychopy.hardware import keyboard

win = visual.Window([800, 800], pos=(0, 0), monitor='testMonitor')
instruction1 = visual.TextStim(win, text='First Instruction')
instruction1.draw()
win.flip()

k1 = keyboard.Keyboard()
event.waitKeys(keyList=None)
keyPressed = k1.getKeys()[0]
print(keyPressed.name)

For more details see the demo mentioned above :slight_smile:

Thanks,
Becca