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