Problem about making self paced reading experiment for online

Hi, I am a newbie for not only PsychoPy, but overall programming.

I built an experiment for the self paced reading changing the stimulus by pressing the space bar (by the request from my professor).
The experiment runs well at both the PsychoPy running and Pavloiva pilot running.

However, I got a big problem about the case if people enters a key which is not a space bar.
If you press a key other than the space bar, the experiment lose the response, so there is no other way but to forcibly shut it down.

I added the code that makes the loop continue if the key gotten is not space bar nor escape, but the problem doesn’t solve.

Anyone can help, please?

SelfPacedReading.psyexp (25.0 KB)

Probably you can get there without any code. Try this: in the response component, specify space as response and only end routine upon valid response.

I’m not sure I understood you correctly.

Actually, I didn’t make the response component, but only the code component.

But as you said, I created the response component that gets only the space bar as a response.


Well, but the error still remains, even I changed the priority of response into the first.

This is how my new response looks like.

Did I read you clearly? Or are there other ways to solve the problem?

Hello BJ_Kim.
I just finished my own Self-Paced Reading Task and your keyboard component is fine. Of course, you can’t force end routine as you need the rest of the words in the sentence to appear in the same repeat. I can assure you my keyboard component looks the same, so it must be something else. Maybe the problem is within the code component - the function where you “catch” the keyboard response. Do you use event.getKeys('space') ?

1 Like


I really appreciate!!


Thanks @pavle! And sorry @BJ_Kim; in my original reply I was confused with mouse responses

Hi BJ_Kim! I had the same problem and just solved it in another way. I moved the “i = i + 1” line out of the “else if” loop and place this line to the end of the “while” loop. In that way, the value of i will be updated even if the key pressed is not space. Here is a screen shot of the codes that I used.
Screen Shot 2021-04-25 at 1.42.40 PM

1 Like