Hi Monika, it would help if you have comments in your code to explain what should be happening. I can give some hints as to what is going wrong, although it is hard to tell you exactly what to do, as I’m not clear what the task is. But here goes.
RespEvent=event.getKeys() will happen just once per word. It happens before any stimuli have been drawn. It is unlikely it will detect any keypress here, although it is possible that it will detect keypresses that were made earlier and are still waiting in the buffer.
You then draw
rand_item but while it is being displayed, you don’t do any keyboard checking via
getKeys() so no new keypresses will be detected.
You then have a series of checks of the
RespEvent variable. Note that this was created before
rand_item was drawn, so it will either be empty, or reflect a keypress made much earlier. It won’t have changed during the presentation of
You then continue drawing
rand_item but now with
text_2 as well. During this interval, you are checking for keypresses and assigning them to
RespEvent. Note if there is more than one response, only the last will be kept, as each new response overwrites the previous one. No action is taken in response to any keypress (e.g. calculating a reaction time or storing the response).
You then go back to the beginning of the loop and do a single
getKeys(). This will have the effect of erasing anything stored in
After showing the
rand_stim again, you do various checks of
RespEvent, but it very likely contains nothing. etc etc.
So you need to work through your code line by line and imagine what is happening with keypresses. It is only during this period:
for frameN in range (TextStop):
that you are continually monitoring the keyboard, and yet nothing is done in response to it.
Perhaps what you should do is re-post the code above but add comments to say what you want to achieve at each point (i.e. what is being displayed, what the subject should do, and what we are measuring (e.g. reaction time relative to event x, judgement of category y, etc)). You know what you are doing, but we can’t really tell just from the bare code.