Converting py code to JS

Hello!
I couldn’t get my PY code to work on the online version of my experiment of Pavlovia, but it works on the desktop version. I read that you need to translate the PY code into JS. Would anyone be able to help me with this? I have no experience with JS. Here is my code:

templist=R1Name.keys
if templist.count('return')==1:
    R1Name.keys.pop()
    R1Name.keys=''.join(R1Name.keys)
    R1Name.rt=R1Name.rt[0]
    continueRoutine=False
elif templist.count('space')==1:
    R1Name.keys.pop()
elif templist.count('lshift')==1:
    R1Name.keys.pop()
elif templist.count('backspace')>=1 and len(R1Name.keys)>=2:
    R1Name.keys.remove('backspace')
    R1Name.keys.pop()
    msg=msg[:-1]
elif templist.count('backspace')>=1 and len(R1Name.keys)==1:
    R1Name.keys.pop()
elif (len(R1Name.keys)-1) == numkeys:
    msg=''
    msg=msg.join(R1Name.keys)
numkeys=len(R1Name.keys)

Hi @willi4cm, it looks like you are attempting to write text on screen? If so, have a look at the example already written that works for both Python and JS. You can download the task and use the code for your own task.

Code: https://gitlab.pavlovia.org/demos/textinput
Demo: https://run.pavlovia.org/demos/textinput/html

1 Like

Yes! I want the participant to be able to type in a response. Thank you so much!