In my experiment, I would like to display the keypress duration time to the participant.
So far I can only display the amount of time from when the Textsim is created until the space button is released (str(i) in the code).
Just to be clear I would like where it displays the string (i) in the code to actually display from when the space bar is pressed until it is released. Is this possible?
I have attached a snippet of my code below:
Thanks in advance,
# Question Screen i = 0 loop_1 = True while loop_1: instruction = visual.TextStim(win, text ='Do you prefer cats or dogs?\nOption A: Cats\n\ Option B: Dogs\n\ Thinking time =' + str(i) ) instruction.draw() win.flip() q_keys = kb.getKeys(["space"], waitRelease=True) if len(q_keys): f = ('Space_always', q_keys.name) d = ('RT1', q_keys.rt) c = ('Press Time', q_keys.duration) loop_1 = False i = i + 1 win.callOnFlip(kb.clock.reset) win.callOnFlip(kb.clearEvents, eventType='keyboard') # Response Screen instruction.text = 'Press the key "t" for Option A \n Press the key "y" for Option B ' instruction.draw() win.flip() loop_2 = True while loop_2: a_keys = kb.getKeys(['t', 'y'], waitRelease=False) if len(a_keys): b = ('Answer', a_keys.name) a = ('RT2', a_keys.rt) loop_2 = False