Howdy, Stranger!

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

Supported by

[open] Need help collecting the time a key was pressed.

edited January 2013 in OpenSesame


I'm currently trying to make an experiment where the participant has to rate a set of eyes on a scale of 1-5. This part of the experiment I've found very easy to set up.

Unfortunately I also want to test the prospective memory of the participants at the same time, so need to record their keyboard press of the letter 'Q' when they have perceived 2 minutes to have passed. I'm new to open sesame and haven't the faintest idea how to have a participant rate eyes whilst also having a response to a totally different task at the same time, which I'd need a time stamp with to know how close the response was to 2 minutes actually passing.

Any help would be much appreciated.

Thank you very much,



  • edited 8:40PM

    Hi Mark,

    Welcome to the forum!

    If I understand correctly your trial sequence is as follows:

    • Firstly, you present a stimulus (a pair of eyes).
    • Secondly, participants rate this pair of eyes on a 1-5 rating scale.
    • This is followed by a blank interval during which participants have to estimate when 2 minutes have passed since stimulus presentation (and not since their response on the rating scale).
    • Finally, participants press "q" if they think the two minutes have passed.

    Like you said, you will need the time stamps of the stimulus and the keyboard response for this. Luckily, these are very easy to obtain: The time stamp of any given item is contained by an existing variable called "time_" followed by the name of the item. So, for example, the variable "time_my_sketchpad" contains the time stamp of the last time the item "my_sketchpad" was called.

    When applying this to your situation, I would suggest the following procedure:

    • Firstly, append the following items to your trial sequence (which I think you already did): a sketcphad item to present the eyes, a rating_scale item to collect the first response (a mouse click?) and a second sketchpad item to present a blank screen during the remainder of the interval. Set the duration of the latter to 0.
    • Secondly, append a keyboard response to collect the q-press.
    • Next, append a third sketchpad item and set its duration to 0. This is just a dummy item and will be used to obtain the time stamp of the q-press (see below).
    • Append an inline_script item. This is because we need a bit of Python inline code to determine the duration of the target interval (between stimulus and q-response).
    • And finally, append a logger item to make sure all variables are logged at the end of every trial.

    The overview of your experiment should now look something like this:

    The following script should give you an idea of how to determine the interval of interest per trial. Simply put this Python inline code to the Run phase tab of your inline_script item. See the comments for a more detailed explanation.


    The complete example experiment can be downloaded here. Simply 'save as' with the extension ".opensesame".

    Finally, note that can have a look at the list of existing variables simply by clicking the "show variable inspector" button in the main toolbar, like so:


    I hope this helps! Please let us know if you have any further questions!

    Best wishes,


Sign In or Register to comment.