| Reference | Downloads | Github

Buttonbox_code component

Is there a documentation on how to insert a code component to make the buttonbox work? I have this buttonbox But I dont know where to insert which parts of the relevant code?
Any kind of help is highly appreciated since it is very very urgent.


Hello Ezgi,

I’m not familiar with the button box, so I’m just going off the online documentation. They helpfully provide a PsychoPy example here:
but note that you shouldn’t use the waitButtons() or waitKeys() functions in a Builder experiment: they will conflict with Builder’s timing by inserting an indefinite pause while it waits for input. Instead you should use the getButtons() or getKeys() functions that just check the current state of the button box rather than waiting for input.

In the “begin experiment” tab, put something like this to import the necessary software package and to connect to the box:

# import the rusocsci.buttonbox module
from rusocsci import buttonbox 
# make a buttonbox
bb = buttonbox.Buttonbox()

Then in the “every frame” tab, you would use this function to check if a button is currently being pressed:

keys = bb.getKeys()

This then gives you a list of what buttons have been pressed at that instant. You will need to do something with that variable, as required.

I don’t think the rusocsci package is included in PsychoPy (perhaps its should be…) So you will need to install it if the code above causes an error at the import stage. Do that by following the instructions here:

Hello Michael,

Thank you very much for the response.
I installed the package, and inserted the codes as you described.
Now, I dont get any errors, but the first trial just gets stuck and does not allow me to go onto the next.

Could you maybe tell me how much terrible idea is to use the laptop keyboard for RTs. Would this be fatal?

Thank you again, you always help me!

You’ll need to do something once the keypress is detected, e.g:

keys = bb.getKeys()

if keys:
    # do something with the keypress, then:
    continueRoutine = False # end the trial

Not fatal, but I suspect this button box will have a much lower lag than the keyboard. But you’re still only checking it every 16.66 ms, so although it will likely be more accurate, it is not necessarily more precise. I haven’t looked further into the documentation to see if there is some way of getting better time stamping from it.

1 Like