About multiple keyboards

Hey everyone!
I’ve tried to use PTB in our experiments. In our experiment design, we’ve prepared 2 extra diy-keyboards, one contains numbers from 0-4 and the other contains 5-9. The code is as follows:
-----------------------------------CODE-----------------------
KbName(‘UnifyKeyNames’);
deviceIndex = ;
KbQueueCreate(deviceIndex)
KbQueueStart(deviceIndex);
------- Skipping some experiment design here --------------------
[pressed, firstPress, firstRelease] = KbQueueCheck(deviceIndex);
Ifpress=[Ifpress pressed];
if pressed == 1
pressnum=min(firstPress(find(firstPress~=0)));
start_press=[start_press pressnum];
keyCode = find(firstPress, 1);
theText = KbName(keyCode);
switch keyCode
case {49,50,51,52,53}
outputlist=[outputlist 0];
outputlistorig= [outputlistorig keyCode-48];
case {48,54,55,56,57}
outputlist=[outputlist 1];
outputlistorig= [outputlistorig keyCode-48];
otherwise
outputlist = [outputlist -1];
outputlistorig = [outputlistorit keyCode-48];
end
elseif pressed==0
outputlist=[outputlist 0];
outputlistorig=[outputlistorig -1];
start_press=[start_press 0];
end
----------------------------------------CODE----------------------------------------
However, in our experiment, we found that when the subjects pressed the diy-keyboards, sometimes the output of “pressed” remains 0 (which means it did not receive the press), but sometimes it can be 1( which means it receive the press). I tried to use GetKeyboardIndices function but it only returns the main keyboard. I used PsychHID(‘devices’) to get the deviceNumber, but I could not find the deviceNumber from the struct it returns, only the “index”. And ‘index’ can not be used as a parameter in KbCheck. So how to solve the problems?

Assuming you use the paid Psychtoolbox 3.0.20 or later, what’s your support authentication token? PsychLicenseHandling('AuthenticationToken') will print it.

Which operating system?