I’m having a problem coding multiple key presses. I want to be able to see all responses instead of just the last responses, but I am getting an error that I will attach to this post. Please let me know if you have any suggestions.
Okay, I tried replacing keys_pressed with the new function. I’m still getting errors. Does it have something to do with “keys = event.getKeys()” being in parentheses? I thought that brackets were needed to output multiple responses. I will attach the new code and screenshots of the errors. Error 1 shows the error with the entire code (using code in the begin routine and each frame tab), and error 2 is only showing it for the each frame tab, without adding the definition in the begin routine tab.
Why have you put keysPressed.append() in begin routine tab when it is in each frame in your original screenshot? If you put that line where it was suggested above it should work fine. The error relates to trying to assign an empty string to the function keysPressed.append() - just delete the =’’ and the error will go away.
Could you perhaps briefly explain what exactly it is you’d like to achieve? Specifically, why can’t you use the “Store: all keys” functionality of the Builder keyboard component?
Hi Jan,
Because Emily needs to handle other aspects of the keys conditionally in code, and that would conflict with a keyboard component.
Emily:
You can’t assign a value to keysPressed.append(). It is a function, not a variable. That line should be
keysPressed = ‘’
You don’t seem to have actually inserted the code I suggested in the other thread under the section of code for when t < 2:
elif t < 2.0:
# for the first key press:
if not end_at_2s:
thisExp.addData('RT', t)
end_at_2s = True
# for all key presses:
for key in keys:
keys_pressed = keys_pressed + key # concatenate multiple keys
thisExp.addData('rating', keys_pressed) # update the data
which should now fix the issue about adding keys to a list of keys.