psychopy.org | Reference | Downloads | Github

Keyboard component is not working

PsychoPy version: 3
Hello,
I wanted to implement an open question to my questionnaire. Therefore, I used a keyboard component and allowed all keys because the participants should be able to write down full sentences. But unfortunately, if I try to run the project nothing works and the following error message appears:

screen_textq += Qualitaet_Antwort.keys #should be string but is empty list
TypeError: must be str, not list

These are the components I am using:

  • Qualitaet_Antwort (Keyboard component)
  • AntwortAlter_3 (Text component for the answer the participants are typing in)
  • Qualitaet (Text component for the question)
  • codeRecall_9 (code component)

This is my code in the code component for Begin Routine:

screen_textq = ''
idx = 0

This is my code in the code component for Each Frame:

#idx - iteration index, set to 0 in  begin routine
#skip first iteration to load screen
if idx > 0:
    #wait for keypress
    event.waitKeys()
    #Keyboard Component variable set to Qualitaet_Antwort,
    # and save only last key. write that key to textbox variable: screen_textq
    screen_textq += Qualitaet_Antwort.keys #should be string but is empty list
#iterate index
idx += 1

Do you know how to solve this? I also tried a lot of other codes to create a good working keyboard but always had some struggles with it. Thank you in advance!

Have a look at this demo https://gitlab.pavlovia.org/demos/textinput