| Reference | Downloads | Github

Keyboard and GUI Issue

Hi guys,

Before I ask this rather silly question, I know the obvious answer is to just change the keylist value in my loop, but I just would like an answer out of simple curiosity …

Basically my issue is that I initialise the gui at the start of my experiment, followed by the first stage in my experiment which shows the participant a set of instructions where they are told to press the enter key to proceed to the next stage.

My issue is that when filling out the gui if the participant presses enter rather then clicking through the gui, it skips my instructions.

I have added some snippets of the relevant code below.

Thanks in advance,


psychopyVersion = '2020.1.2'
expName = 'eeg_v4_logic'
expInfo = {'participant': '', 'session': '001'}
dlg = gui.DlgFromDict(dictionary=expInfo, sortKeys=False, title=expName)
if dlg.OK == False:
    core.quit()  # user pressed cancel
expInfo['date'] = data.getDateStr()  # add a simple timestamp
expInfo['expName'] = expName

And the first stage:

win = visual.Window([400,300], monitor="testMonitor") # for testing obv
kb = keyboard.Keyboard()
# 8. Intro (Instructions) - done

intro = visual.TextStim(win)
intro.text = 'Hi, please follow these instructions :) \n \
Press return when you are ready to begin the experiment\n'
win.flip() # reset the clock to record a response time and clear events

intro_loop = True
while intro_loop:
    intro_keys = kb.getKeys(["enter"], waitRelease=True)
    if len(intro_keys):
            intro_loop = False

Could it be that a Return key press is still in the event buffer, when you start the loop?
You could check for this possibility by calling getKeys once before the loop an logging the key presses. This should also empty the event buffer.

This worked thanks