This component allows you to connect to a Cedrus Button Box to collect key presses.
Before using your Cedrus response box make sure to install the required drivers. From there, your response box should plug straight into your USB port!
Everything in a PsychoPy® experiment needs a unique name. The name should contain only letters, numbers and underscores (no punctuation marks or spaces).
The time that the button box is first read. See Defining the onset/duration of components for details.
Governs the duration for which the button box is first read. See Defining the onset/duration of components for details.
If this is checked, the first response will end the routine.
What information to save, how to lay it out and when to save it.
This field lets you specify which buttons (None, or some or all of 0 through 7) to listen to.
Which button events to save in the data file. Events and the response times are saved, with RT being recorded by the button box (not by PsychoPy®).
If selected, a correctness value will be saved in the data file, based on a match with the given correct answer.
If selected, any previous responses will be ignored (typically this is what you want).
Parameters for controlling hardware.
This is only needed if you have multiple Cedrus devices connected and you need to specify which to use.
Set this to True to use the button box timer for timing information (may give better time resolution)
buttonBox.keys : A list of keys that were pressed (e.g. 0, 1, 2 …)
buttonBox.rt : A list of response times for each keypress
If you want to detect both key presses and key lifts from your cedrus response box, at the moment you will need to use custom code. Add a code component to your Routine and in the Begin Experiment use:
import pyxid2 as pyxid
# get a list of all attached XID devices
devices = pyxid.get_xid_devices()
dev = devices[0] # get the first device to use
Then in the Each Frame tab use:
dev.poll_for_response()
if dev.response_queue_size() > 0:
response = dev.get_next_response()
print(response)
The printed response will return if the key is being pressed (i.e. a key down event) or not (i.e. a key up event):
{'port': 0, 'key': 0, 'pressed': True, 'time': 953}
{'port': 0, 'key': 0, 'pressed': False, 'time': 1298}
{'port': 0, 'key': 0, 'pressed': True, 'time': 2051}
{'port': 0, 'key': 0, 'pressed': False, 'time': 3140}
See also
API reference for iolab