Getting Time of Keypress

Hi

How can I get the exact time of key press?

psychopy.event.getKeys takes a timeStamped argument, which you can set to True.

1 Like

Thanks a lot. but there is a TypeError:
“getKeys got an unexpected keyword argument ‘timeStamped’”.

The only reason I can think you’d get that error is if you have a very old version of psychopy or if there’s a typo in the word timeStamped (check the case). Can you post that snippet of your code and the exact text of the error?

The version is v3.1.5.
I have put this code in the BeginRoutine tab:
a = Target_Response.getKeys(keyList=[‘k’,‘s’], timeStamped=True)
Target_Response is my keyboard component.
here is the Error: “getKeys got an unexpected keyword argument ‘timeStamped’”.

I see, I’m less familiar with the newer syntax. You want these docs, the example shows how to get RT. If you want absolute time I believe you’d have to relate the RT to the start time of kb.clock

1 Like

Thank you so much

Hi There,

This post might be useful

Also try using the demo in coder view >demos> input >keyboardNEW

Becca

1 Like

The issue here is that your are confusing the event module (which has a function called event.getKeys() that allows you to check if a key has been pressed), with Builder’s Keyboard component, which has already done the checking for you, and you just query what it found. So you can’t tell it after the fact what list of keys to check for and whether they should be time stamped or not: those decisions are already made in the settings applied within the Builder Keyboard component dialog box.

Regards, you shouldn’t be using the event module anymore: as Rebecca suggests, you should use the new Keyboard class instead, which performs much better.

Builder’s keyboard component also uses this approach in the latest version. But you need to get it straight in your mind whether you are actually using code to check for keypresses in real time, or just querying Builder’s keyboard component after the fact.

2 Likes

thanks a lot

Thanks a lot