Keypress and timer recording delay

Quick summary:

Trying to use xojo to run scientific research, I am trying to record a person’s response time when an image is shown. I’ve set up some code to have a timer start recording when the image is shown and end when a person has pressed a button. This is repeated 1000 times with some intermittent pauses gated by button presses and timer slideshows. Point is, when I am look at people’s performances, I am noticing gaps in times recorded (e.g., no responses from 300-370 milliseconds) but large recorded times at 371 milliseconds. My working hypothesis is that there are some pockets of delay that the computer does not register a button press and then records this action at the next available moment. No code is written to produce these events.

Here is a visual.

Can someone fill me in on what is going on please? Broad stroke explanations would also be happily accepted. Essentially, I am trying to figure out if is a coding issue or some computer-code compatibility (it is a 2013 desktop mac I believe)?

Which event are you launching the timer from - KeyDown or KeyUp?

KeyDown

Have you tried moving that to key up as there should be some milliseconds worth of delay as the key has to come up after it has been pressed.

  • Move your code to the KeyUp Event
  • Then add Return True under your KeyDown event (which will fire the KeyUp event)

Hope this helps.

Mike

PS Welcome to the Xojo Forum @Jong_Han_Lee1

2 Likes

Why use a timer? Record the Milliseconds when the image is displayed and again in KeyDown. Subtract the two. I think the timer is introducing at least part of the issue.

3 Likes