Key duration of overlapping key presses

OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): 2020.2.1
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?:

Does the .duration of the keyboard class still work if key presses overlap? I.e., when typing quickly (as my participants will be doing) some key presses will slightly overlap, so that the second key is pressed just before the first is released, but I want a duration for all key presses.

I am using the code in this link,

but it means that I don’t get durations for overlapping keys because the key status is set to ‘down’, followed by another ‘down’ before the first key is released. Because the duration is derived from differences in this status list (i.e. one key has a ‘down’ status followed by ‘up’), any keys that slightly overlap when pressed don’t get a duration.

What did you try to make it work?:
I have tried various different ways of coding this without any success but I also need the code to work when pushed #online and am wondering if it is even possible? I am hoping someone can tell me whether they know if this is feasible and could point me in the right direction re. coding this, as I couldn’t find an answer to this issue anywhere.

@Becca So sorry to tag you - I am wondering if you know the answer to this? If this isn’t actually feasible within PsychoPy/javascript I will have to look at using a different program for my experiments.

Many thanks!

Hi There!

Yes this should work no problem! Are you facing specific error messages with your version of the code? or the output just isn’t appearing as you expect?

Thanks!
Becca

Hi @Becca ! Thanks so much for replying.

There’s no error message, I just don’t get the correct number of duration times for the number of keys pressed in the .xlsx file, and I have noticed the number of durations is only correct when I type slowly.

When I type the word quickly I might get 5 durations for 7 keys pressed for instance, and I am pretty sure it’s because some of the keys pressed slightly overlap with each other. In particular, my participants are a clinical group that will have movement difficulties and one of the things I need to capture is whether some keys are held down for too long/kept pressed whilst other keys are pressed etc., so I really need to capture this information accurately.

Here is my experiment, in case you need to have a look. If you click run (select ‘Group A’ and the attached spreadsheet will work), it is set up just to run one trial (the word ‘linear’). When it says ‘type’, if you type the word and press enter, you can press ESC once you see the slider and check the data file to see what I mean!

The code for the key durations is in the component called ‘keyDuration’ in the routine called ‘task’.

Any help HUGELY appreciated :slight_smile:

StudentExperiment_counterbalanced.psyexp (119.4 KB)
control_groupA.xlsx (15.6 KB)