psychopy.org | Reference | Downloads | Github

Branching Logic working for Psychopy but not Pavlovia

Hi,
I have a keyboard inserted in a routine and based on the key press, I want a corresponding loop to be presented while the remaining loops are skipped. I have a total of 7 possible loops. The following code works in Psychopy, but not Pavlovia. I believe I need to move this code from End Routine to Each Frame for the code to eventually work, but right now the issue is that keys.lower is not a function according to Pavlovia. Would anyone know how to resolve this issue?

if (key_resp.keys.lower() == '1'):
            DoTradConfID1=1
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=0
elif (key_resp.keys.lower()  == '2'):
            DoTradConfID1=0
            DoTradConfID2=1
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=0
elif (key_resp.keys.lower()  == '3'):
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=1
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=0
elif (key_resp.keys.lower()  == '4'):
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=1
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=0
elif (key_resp.keys.lower()  == '5'):
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=1
            DoTradConfID6=0
            DoTradConfReject=0
elif (key_resp.keys.lower()  == '6'):
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=1
            DoTradConfReject=0
elif (key_resp.keys.lower()  == 'x'):
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=1
elif (key_resp.keys.lower()  == 'X'):
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=1
else:
            DoTradConfID1=0
            DoTradConfID2=0
            DoTradConfID3=0
            DoTradConfID4=0
            DoTradConfID5=0
            DoTradConfID6=0
            DoTradConfReject=1

The error that shows when it reaches this routine in Pavlovia is: TypeError: key_resp.keys.lower is not a function.

(“key_resp” is the name of the keyboard component)

Thank you so much!!

As per my crib sheet .lower needs to be manually translated to .to LowerCase

However, you don’t need to do this for digits so I would just delete .lower

Hi,
Yes, I tried that and I get the same error message when it reaches this routine in Pavlovia (TypeError: key_resp.keys is not a function.).