Js count how many keys have been pressed since beginning of the routine

Hello.

I have a keyboard component track_presses which stores all key presses and does not end a routine.
I want to count how many (space) presses have been pressed at each frame. But trying

keys = track_presses.getKeys(['space','SPACE'])
in each frame
comes out empty always.

kb = psychoJS.eventManager.getKeys(["space"]);
prints out everything from the beginning of the experiment

I’ve referred to another previous posts but nothing has helped.

TIA!

Hello. I do not have an answer for your problem, but I am curious if you or anyone else can provide a solution since I also have a task where I would like JS to keep track of the keypresses and response times during a routine without ending the routine.

I just added a second keyboard component that doesn’t end the routine but tracks the same keys. You can then select “track all presses” in the options.

hope this helps.