KbStrokeWait/KbWait works only sometimes

Hello,

I am running PsychToolbox-3 on Windows 10 and MATLAB R2020b. We are using two Current Designs 2-button Button Boxes, one for each hand. Our experiment worked completely fine for months, until one day it just randomly broke - no errors or changes to anything. Now, KbStrokeWait randomly captures/prints only some of the button presses. Other button presses are not captured/printed as PsychToolbox is unresponsive and the experiment cannot progress. I have included the first instance in which KbStrokeWait is used.

text = ['Welcome to the experiment!\nThe experiment takes about 60 minutes to complete on average.\n' ...
    '\nSome people will take more time and some people will take less time.' ...
    '\nPress any button to continue.'];
DrawFormattedText(screenInfo.curWindow, text, 'center','center', white);
Screen('Flip', screenInfo.curWindow);
[~, keyCode, ~] = KbStrokeWait(-1); %Experiment randomly and unexpectedly gets caught here, even when buttons are being pressed
disp(KbName(find(keyCode))); % for debugging

I have determined that it is not a hardware issue with the computer, button boxes, or any cables. It also doesn’t seem to be an issue with MATLAB itself. When debugging, I can see that the program is getting caught at line 118 in KbWait.m (which KbStrokeWait uses):

<117> % Wait for keypress:
<118> [secs, keyCode, deltaSecs] = KbWait(deviceNumber, 0, untilTime);

No error is shown, and when pressing buttons using KbStrokeWait outside of our experiment (i.e. in the command prompt), each button press is recorded. Additionally, when using the keyboard instead of the button boxes, every keypress goes through. No other lab that uses these button boxes has had a problem with them. I have tried everything I can think of, from reinstalling MATLAB, Psychtoolbox, updating Windows, restricting & disabling keys, using KbWait/KbPressWait, to no avail. Please let me know if you have any ideas.

Probably the old problem of Current Designs devices like FORP reporting too brief button presses, ie. pretending to be a keyboard but not actually acting like one. Searching the forum for words like “Current Design” or “FORP” shows explanations.

The devices can be configured to not misbehave in that way. Or one can use KbQueues (KbQueueCreate/Start/…, KbEventAvail/Get etc.) to record even absurdly brief button presses.

For any further support: → help PsychPaidSupportAndServices

Hello,

Thanks for your response! When using FORPWait, I get this error: FORPCheck: No FORP-Device detected on your system

But PsychHID(‘Devices’) lists the button boxes as a device.

When using KbQueueWait, where forWhat = 0, I get the same issue as when using KbStrokeWait or KbWait.

Any idea as to why this is happening?

Thanks!

I didn’t tell you to use these very old functions, but hinted to a proper solution.

Possibly. For any paid further support, which will contribute to PTB’s development, maintenance and support: → help PsychPaidSupportAndServices