Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

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

noamkarshnoamkarsh Posts: 13
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


  • lvanderlindenlvanderlinden Posts: 292
    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:
    # http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.get
    # 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:
    # http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.set
    exp.set("delay", delay)
    # Pause your experiment for the desired delay by using the built-in OpenSesame
    # function 'sleep()'. See also:
    # http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.sleep

    Does this answer your question?

    Best wishes,


    Lotje van der Linden - http://www.cogsci.nl

  • noamkarshnoamkarsh Posts: 13
    edited 10:53AM

    it works great!
    thank you!

  • lvanderlindenlvanderlinden Posts: 292
    edited 10:53AM

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

    Lotje van der Linden - http://www.cogsci.nl

Sign In or Register to comment.