| Reference | Downloads | Github

Masked feedback from typing numbers



thanks for this forum and the helpful answers here.

I read the discussion above after I have encountered a similar problem and I think that the solution suggested here can also help me. I tried your code component in order to present stimulation depending on keyboard response. The problem is that I don’t use a movie- my stimulation is shapes/polygons that should appear after each keyboard press. Without the movie file, the “Each frame” tab is useless and the value of "number_pressed " stays “true” after the first key press.

Is there a way to change the code to re-initialize the variable "number_pressed " after each press?
*Attached is the script of my task (25.3 KB)



Using the same condition to end one item and start another?

It doesn’t make a difference what stimuli you use: the code in the “each frame” tab runs regardless. Please show the actual code snippets you are using and describe the problem in detail. No one is likely to read through an entire experiment .py file and then be able to understand your issues. Please break it down for us.



Hello and thanks for the response,

I don’t really understand the code myself but I’ll try my best to explain the task through the pictures of the builder:

In my experiment, subjects learn a sequence of symbols that represent numbers to be typed. In this part of the task they are tested on the sequence that they have learned. After the presentation of 5 symbols sequence they need to type the 5 number that correspond to this seq. I tried to create a routine in which after a press of one number a feedback sign in the form a dot is appearing in the top of the screen, the first key response is over and the next one begin, and once again after pressing the second number a second dot is add and so forward… the problem I have is trying to terminate the first key press and then the second and all the rest. I tried using the code as you suggested above but it only worked for the first key press.

Thanks again,



I’ve moved this to a new topic, as it isn’t really related to the previous one at all. I’ll try to come back to this tomorrow. If not, give me a prompt. The solution to this will be a lot simpler than what is currently implemented.



I’m glad to hear that there is a simple

I remind
you, if possible, to post your suggestion on the topic.





  • Delete all of the keyboard components in your routine.
  • In the code component, put something like this in the “Begin routine” tab:
dot_visibility = [0, 0, 0, 0, 0]
responses = []
n_responses = -1
  • Move the code component to be above all the other stimuli (right-click on its icon to move it). This means the stimuli always have access to the latest calculated values.
  • In your first polygon stimulus, set the “opacity” field to be dot_visibility[0], set to update on every frame. Do the same for the other stimuli, incrementing the index number for each.
  • The start time should be 0 and the duration left blank.
  • In the “Each frame” tab, put something like:
key = event.getKeys(['1', '2', '3', '4'])

if key:
    responses.extend(key[0]) # remember the key press
    n_responses = n_responses + 1   # zero-based counting
    dot_visibility[n_responses] = 1 # update next dot's visibility
    if n_responses == 4:  # end after five responses
        thisExp.addData('responses', responses) # store in the data file
        continueRoutine = False

Wow, that works amazing! And so much more organized than what I tried so far. Thank you so much.

There is one more thing- I can live with the task as it is now, but if it is possible, I would like to make one more improvement: After I changed the task according to your suggestions it is really works well and every stimulus appears after each key press. The problem is that the last stimulus never get to appear since the routine ends when n_responses = 4 . Is there a way to end the routine slightly after the stimulus has been presented?
Another issue is how to save the response time? So far it has been automatically saved along with the number that was pressed but now this cell is empty.

appreciate your help,