Storing duration of response (keypress)

Hi everyone,

I am building a simple experiment in version2022.2.4 and am wanting to record how long response keys are pressed for. I have played around a bit and understand that I can record the onset and offset times for when the response window begins/ends, and also save data on reaction times for responses but I’m not sure if there is a way I can record how long the response key was pressed for? Any advice here would be greatly appreciated! I am just switching over from Matlab and am still learning.