Getting written responses

Mac OS Catalina 10.15.3

PsychoPy3

Hello all!
I’m trying to get typed responses on PsychoPy. I’m not good at coding and this is my first time. The issue is that when I press “backspace”, “return” or “space” on the keyboard, it seems to work but then the key name appears on the screen.
Can anyone help me?
Thank you!

Coder:

Begin routine:

screen_text = ''

Each frame:

if("backspace"in key_Resp.keys):
    key_Resp.keys.remove("backspace")
    if(len(key_Resp.keys) > 0):
       key_Resp.keys.pop()
    
elif("space"in key_Resp.keys):
     key_Resp.keys.remove("space")
     key_Resp.keys.append(" ")

elif("return"in key_Resp.keys):
     key_Resp.keys.remove("return")

    if(len(key_Resp.keys) > 2):
       screen_text = ''.join(key_Resp.keys)
       thisExp.addData("recall_resp".screen_text)

    continueRoutine = False

    screen_text = ''.join(key_Resp.keys)
  1. That seems contradictory. What does “it seems to work” mean?

  2. To understand what is going wrong in code like this, it is useful to insert some (temporary) debugging code at strategic points. e.g.

    print(key_Resp.keys)

and check that it matches your expectations at that point in the code.

Hi @GIULIA_SFRISO

I had the same problem with a similar code. However, I used the code from the post below and it worked: