Missed keypress with KbStrokeWait

Hi. I am using Psychtoolbox on Windows 10, for fMRI. The trigger pulse from our scanner is translated into a keypress (the “9” key), and I’m using KbStrokeWait to trigger my paradigm, with the following code:

KeyToPress=KbName(‘9(’);
RestrictKeysForKbCheck(KeyToPress);
KbStrokeWait;

This works most of the time, but occasionally it misses the trigger. If I look at this code at the command line, I see that occasionally, the terminal registers the “9”, but still waits for the next 9 before it returns to the prompt.

I’m assuming that this is happening because the keypress is very rapid and it happens between calls to KbWait, which is in an infinite loop.

Is there a way to hold the keypress in the buffer, so that I can retrieve it on the next call? Or some other way to fix this problem?

Thanks for any advice.

Best,

Mark

help KbTriggerWait is what you want to use. If you appreciate this help and ongoing development and maintenance of Psychtoolbox, or require further assistance, please get your lab to buy a 150 Euros + Tax community membership with priority support:

http://psychtoolbox.org/contribute

Best,
-mario

Thanks, and yes, I agree, we have gotten a lot out of this software, and we have the funding to support you guys!

image001.jpg

Thats great to hear Mark! We direly need the funding, almost exclusive so that Mario, the blood and soul of PTB, can have a living wage. If you are able to afford more than one such membership (support hours), please do consider buying multiple :slight_smile: