psychopy.org | Reference | Downloads | Github

Key Press Duration values are greater than the number of key presses/inaccurate

URL of experiment: ToneTask [PsychoPy]
Gitlab: Fareeha Rana / ToneTask · GitLab

Description of the problem: I’m looking to record the duration of multiple presses of the same key during a given trial. The task premise is for participants to replicate a tone sequence using the spacebar. The experiment is running OK online, but the output file isn’t recording the durations properly–even though it is doing so offline.

I used this comment to add code snippets to record keypress durations {Measuring key lift time relative to stimulus onset - #4 by milsandhills} based off of the sample experiment here {Measuring key lift time relative to stimulus onset - #3 by Becca}. I have looked at other discussions posted on the forums that require something similar, but they haven’t been very helpful so far (or, possibly, I am not properly understanding the root of the issue).

More details:

In the output file, the first keypress duration seems to be recorded properly, but then the subsequent values iteratively go up by a small amount (e.g., 5.84, 5.99, 6.12 etc.). The output ‘durations’ per trial is far more than the number of keypresses, so I can only guess that it’s recording something in addition to the actual keypresses. That is, when I press (and release) the space bar three times, I still get a list of 20 or so values. Similarly, the variable that stores the keypresses (series of 'up’s and ‘downs’) is much longer than the keypresses within the trial. But the time is resetting for each trial, so I don’t think the experiment is recording all cumulative keypresses.

Any insight would be incredibly helpful (and if any more information would be helpful, I’d be happy to offer it). Thank you!

Hi @FSRana , I just wanted to add to this thread as you tagged one of my previous questions - I never managed to record key durations successfully online. I had to scrap that measure and use more simple measures for my experiment, but I appreciate that doesn’t seem suitable for what you’re trying to do. I’m sorry this isn’t helpful, but if you manage to get this working, please do post the solution!

Ah, thanks for the update, that’s actually helpful to know! I’ll try branching out from those code snippets; perhaps that’ll result in a workable solution. And of course, I’ll definitely post it!

1 Like

You might find it easier to use mouse button presses than keyboard.

1 Like