Getting negative reaction times on windows

Dear Psychopy users,
I am getting some negative reaction times which seem to be related to very early key presses, I obtained them by pressing repeatedly in order to simulate accidental early key presses. The issue shows up on Windows (10) with last standalone version of Psychopy (I tested the same code on Ubuntu with Psychopy 2020.2.10 and I could not reproduce the issue). I am probably missing something here, I have not collected reaction times with Psychopy for a while and I would like to understand whether the problem is in my code (quite likely) or there is something else there. Here it is a toy example of the code that gives the same issue:

from psychopy import visual, core
from psychopy.hardware import keyboard
import numpy as np

stim_duration = np.repeat([1.5, 2, 2.5, 3, 3.5], 5)
win = visual.Window([800,600])
stim = visual.TextStim(win)

clock = core.Clock()
timer = core.CountdownTimer()
kb = keyboard.Keyboard()

for trial, dur in enumerate(stim_duration):
    rt = {"trial": trial, "rt": []}
    stim.text = f"trial {trial}"
    while timer.getTime() > 0:
        keys = kb.getKeys(['left', 'right'])
        if keys:
            resp = keys[0].rt

I would be glad if someone could give me any suggestions.
Thanks a lot

I guess this RT is going to be two times subtracted

HI Wen,
thanks for replying, but I guess I don’t understand your point. Do you mind clarifying your answer?

A further question that might help me understand my issue: Does getKeys() compute the reaction times by subtracting tDown from the time provided by kb.clock.reset()? If so, how can I get negative reaction times?

If you use getKeys(),Since the kb.clock.reset() method resets the time, which is now equal to resetting the time every enumeration when getKeys() is too short is negative

Hi Wen, that’s what I thought as well, thanks for the help.

Hi wen,

How do you fix that though? What’s the alternative to getKeys()?

I’m not sure what you’re trying to solve, why you’re using getKeys ()

I am getting negative RTs and can’t figure out an alternative to getKeys() to work around it.

Can you check out my colleague’s post? Mismatch reaction times Mac and Windows ? (Negative RT)