No announcement yet.

Measuring the duration of a button press

  • Filter
  • Time
  • Show
Clear All
new posts

  • Measuring the duration of a button press

    Hi All, I am using superlab 5 and as part of the experiment I want to measure the duration that participants press the spacebar key for. Is there any way I can do this?


  • #2
    - Uncheck the Ignore the key release option in Participant Input.

    - Create a response for both pressing and releasing the space bar.

    - Create a timer parameter to measure the duration of the space bar being pressed.

    - In your events, set feedback so that pressing the space bar starts the timer and releasing the space bar pauses the timer.

    I've attached an example experiment for you to use as reference.
    Attached Files


    • #3
      Hi Arman,

      Thank you so much for your response. I cant seem to open your file for some reason?! I have followed your instructions though and for some reason only the start time that the spacebar button is pressed is being saved....the duration that the button is pressed for (ie, when it is released) is not recording. Also, I would like the event to remain on screen for 5 minutes, ie, so I can record several times that the button is adding the parameter it seems to end the event after the spacebar is released (even though I have requested that the trial only end after a certain time)....sorry for all the questions!


      • #4
        I've attached a zip of the experiment file. Hopefully, this will work for you.

        In the attached experiment, you'll see that the timer value is displayed in another trial. This is because parameter values are only updated once the trial in which they are modified ends. This may be why it seems the duration is not being recorded.

        As for the trial remaining for 5 minutes, this should be possible. Can you further explain your experimental design? This will give me more to work with.
        Attached Files


        • #5
          Hi Arman,

          thank you so much for getting back to me! I will try and open the file you have sent and hopefully it will work!

          Participants are asked to think or avoid thinking about a particular thought for five minutes....whenever they think of that thought they will be required to press the spacebar and hold it down until they think of something this is why I would need the event to remain for five minutes....hope this helps!

          Thank you!


          • #6
            In that case, you may want to loop the block in the experiment I sent you. Also, set it to stop presenting trials after five minutes.

            Let me know how it goes once you've worked with it a bit.