@@ -70,6 +70,30 @@ You can then use the [matlab package manager](https://github.com/mobeets/mpm), t
7070 end
7171```
7272
73+ ## Setting up keyboards
74+
75+ To select a specific keyboard to be used by the experimenter or the participant, you need to know
76+ the value assigned by PTB to each keyboard device.
77+
78+ To know this copy-paste this on the command window:
79+
80+ ``` matlab
81+ [keyboardNumbers, keyboardNames] = GetKeyboardIndices;
82+
83+ disp(keyboardNumbers);
84+ disp(keyboardNames);
85+ ```
86+
87+ You can then assign a specific device number to the main keyboard or the response box in the ` cfg ` structure
88+
89+ - ` cfg.keyboard.responseBox ` would be the device number of the device used by the participant to give his/her
90+ response: like the button box in the scanner or a separate keyboard for a behavioral experiment
91+ - ` cfg.keyboard.keyboard ` would be the device number of the keyboard on which the experimenter will type or
92+ press the keys necessary to start or abort the experiment.
93+
94+ ` cfg.keyboard.responseBox ` and ` cfg.keyboard.keyboard ` can be different or the same.
95+
96+ Using empty vectors (ie ` [] ` ) or a negative value for those means that you will let PTB find and use the default device.
7397
7498## Structure and function details
7599
@@ -106,23 +130,27 @@ It is wrapper function to use `KbQueue` which is definitely what you should used
106130
107131You can easily collect responses while running some other code at the same time.
108132
109- It will only take responses from the ` response box ` which can simply be the "main keyboard" or
110- another keyboard connected to the computer or the response box that the participant is using.
133+ It will only take responses from one device which can simply be the "main keyboard"
134+ (the default device that PTB will find) or another keyboard connected to the computer
135+ or the response box that the participant is using.
111136
112137You can use it in a way so that it only takes responses from certain keys and ignore others (like
113138the triggers from an MRI scanner).
114139
115140If you want to know more on how to use it check its help section and the ` CPP_getResponseDemo.m ` .
116141
117- To select a specific keyboard to be used by the experimenter or the participant, you need to know
118- the value assigned by PTB to each keyboard device.
142+ In brief, there are several actions you can execute with this function.
119143
120- To know this copy-paste this on the command window:
144+ - init: initialize the buffer for key presses on a given device (you can also specify the keys of interest that should be listened to).
145+ - start: start listening to the key presses (carefully insert into your script - where do you want to start buffering the responses).
146+ - check: till that point, it will check the buffer for all key presses.
147+ - It only reports presses on the keys of interest mentioned at initialization.
148+ - It ** can** also check for presses on the escape key and abort if the escape key is part of the keys of interest.
149+ - flush: Empties the buffer of key presses in case you want to discard any previous key presses.
150+ - stop: Stops buffering key presses. You can still restart by calling "start" again.
151+ - release: Closes the buffer for good.
121152
122- [keyboardNumbers, keyboardNames] = GetKeyboardIndices;
123153
124- keyboardNumbers
125- keyboardNames
126154
127155### deg2Pix
128156
0 commit comments