[open] Losing first keypress in self-paced reading task
Hey,
I have a self-paced reading experiment: participants press a button when they have finished reading the current word and are then shown the next word. For this, I loop over pairs of showing a text canvas and collecting a response; one loop for each sentence.
For some reason, in 90% of cases, the first response to the first item in a loop is ignored, so the first item presented requires two keypresses - but only some of the time!
I have no idea why. Any ideas?
I develop this on a Mac, but have observed the same problem on a Windows computer.
I'm appending the critical part of the script, and there's a pastebin to the full one at the end. I can also upload the full script, if that is required.
from openexp.keyboard import keyboard
from openexp.canvas import canvas
cs = []
for w in words: # words is a long list ...
c = canvas(exp)
c.text(w)
cs.append(c)
end = None
rts = []
iscorrects = []
key = None
judge_keyboard = []
judge_keyboard = keyboard(exp, timeout=None)
judge_keyboard.flush()
blank_canvas.show()
self.sleep(250)
for index, c in enumerate(cs):
start = self.time()
c.show()
judge_keyboard = keyboard(exp, timeout=None)
key, end = judge_keyboard.get_key()
print(key)
rts.append(str(end-start))
if (key == "space" and index != w_i) or (key != "space" and index == w_i):
iscorrects.append("1")
else:
iscorrects.append("0")
blank_canvas.show()
self.sleep(100)
judge_keyboard.flush()
Comments
Hi Jona,
For me it works fine. That is, the first words ("Zur Kategorie") always disappear after one key press. The problem, if I understand correctly, is that this does not happen on your system?
The logic of the script looks fine to me, but there's one odd thing. After showing the
sketchpad
you create a newkeyboard
object, instead of using the one that you've already prepared. This could cause problems if creating this object for some reason takes a lot of time, although I don't see why it should.Does it help if you change this:
... to this?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!