Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] How to create different feedback delay for each response key?

edited August 2013 in OpenSesame


I want to thank you for the great help I have got from you with my previous problems.
I want to make some changes in the previous experiment programmed at OpenSesame.
The experiment has four response keys. Clicking on each key leads to a flash (sketchpad) on the screen immediately.

Is there a way that the flash will appear after different delay for each of the four keys?
For example, after pressing the "h" key, a flash will appear after 300 milliseconds, after pressing the "d" key, a flash will appear after 600 milliseconds etc for the remaining two keys.

if necessary, i would be happy to share with you the experiment files through DropBox. If so, what is your address?

Thank you for your help


  • edited July 2013

    Hi Noam,

    Yes, that's certainly possible! To make the response-flash interval depending on the given response:

    Firstly, place an inline_script item between the keyboard_response item and the flash:


    Secondly, place the following Python code in its Run phase tab (see comments for more information):

    # Determine the delay between response and feedback item
    # depending on the given response:
    # To determine the given response, we use the built-in OpenSesame
    # function 'self.get()'. See also:
    # If keyboard responses that do NOT appear in the if-statements below ARE
    # allowed to be given, first make sure your experiment doesn't crash 
    # if a different response is given. You can do this by giving 
    # the variable 'delay' (which we'll use to pause the 
    # experiment) a starting value:
    delay = 0
    # If a certain response is given ...
    if self.get("response") == "a":
        # ... declare the corresponding delay in ms:
        delay = 300
    if self.get("response") == "b":
        delay = 600
        # Etc. for the other responses
    # Set the response for future use in the GUI (e.g. for
    # your logger item) by using the 'exp.set()' function.
    # See also:
    exp.set("delay", delay)
    # Pause your experiment for the desired delay by using the built-in OpenSesame
    # function 'sleep()'. See also:

    Does this answer your question?

    Best wishes,


    Lotje van der Linden -

  • edited 4:44AM

    it works great!
    thank you!

  • edited 4:44AM

    Great to hear!
    Don't hesitate to post any further questions you may have!

    Lotje van der Linden -

Sign In or Register to comment.