# About multiple keyboards

**URL:** <https://psychtoolbox.discourse.group/t/about-multiple-keyboards/5704>\
**Category:** Hardware\
**Created:** [May 12, 2025, 8:51am UTC](https://psychtoolbox.discourse.group/t/about-multiple-keyboards/5704 "2025-05-12T08:51:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wjl511061](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@wjl511061](https://psychtoolbox.discourse.group/u/wjl511061)\
**Post date:** [May 12, 2025, 8:51am UTC](https://psychtoolbox.discourse.group/t/about-multiple-keyboards/5704/1 "2025-05-12T08:51:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [May 14, 2025, 2:25am UTC](https://psychtoolbox.discourse.group/t/about-multiple-keyboards/5704/2 "2025-05-14T02:25:42Z")

</div>

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?
