psychopy.org | Reference | Downloads | Github

"Variables for allowKeys aren't supported for JS yet"

Hello,

I am trying to create a task for online data collection where participants have to select a word from a positive-negative word pair.

To ensure participants don’t repeatedly press the same key I have randomised the position of the words to each of the four corners of the screen. So a positive word appears in one corner and a negative word appears in another corner, but the location is randomised for each trial. Each corner is selected by the respective key on the keyboard (e.g. q is the top left, z is the bottom left, p is the top right and m is the bottom left).

To minimise the number of invalid trials I have set up the task so that the keys can only be selected if the word is in that location. For example, if one word is in the top left and another word is in the top right of the screen only ‘q’ and ‘p’ are valid responses.

We want to use this task for online data collection via pavlovia but at the moment I get the error message

  File "C:\Program Files (x86)\PsychoPy3\lib\site-packages\psychopy\experiment\components\keyboard\__init__.py", line 297, in writeFrameCodeJS
    "Variables for allowKeys aren't supported for JS yet")
psychopy.experiment.utils.CodeGenerationException: Variables for allowKeys aren't supported for JS yet:

Is there some way to work around this so that I am able to restrict the keys being pressed and vary this according to each trial’s word position?

Thank you!

Katie

Code currently used:

#Randomising word position - creating lists for boxes being used, and word allocation
rectangles_used_list = ["both_top", "both_bottom", "lefttop_rightbottom", "righttop_leftbottom"]
word_position_list = ["leftpos_rightneg", "leftneg_rightpos"]

#Randomising word position - shuffle list then assign position values
random.shuffle(rectangles_used_list)
random.shuffle(word_position_list)

if rectangles_used_list[0] == "both_top":
    if word_position_list[0] == "leftpos_rightneg":
        pos_word_position = (-0.65, 0.75)
        neg_word_position = (0.65, 0.75)
    elif word_position_list[0] == "leftneg_rightpos":
        pos_word_position = (0.65, 0.75)
        neg_word_position = (-0.65, 0.75)
elif rectangles_used_list[0] == "both_bottom":
    if word_position_list[0] == "leftpos_rightneg":
        pos_word_position = (-0.65, -0.75)
        neg_word_position = (0.65, -0.75)
    elif word_position_list[0] == "leftneg_rightpos":
        pos_word_position = (0.65, -0.75)
        neg_word_position = (-0.65, -0.75)
elif rectangles_used_list[0] == "lefttop_rightbottom":
    if word_position_list[0] == "leftpos_rightneg":
        pos_word_position = (-0.65, 0.75)
        neg_word_position = (0.65, -0.75)
    elif word_position_list[0] == "leftneg_rightpos":
        pos_word_position = (0.65, -0.75)
        neg_word_position = (-0.65, 0.75)
elif rectangles_used_list[0] == "righttop_leftbottom":
    if word_position_list[0] == "leftpos_rightneg":
        pos_word_position = (-0.65, -0.75)
        neg_word_position = (0.65, 0.75)
    elif word_position_list[0] == "leftneg_rightpos":
        pos_word_position = (0.65, 0.75)
        neg_word_position = (-0.65, -0.75)

#Only allowing keys to be pressed where words are located
if rectangles_used_list[0] == "both_top":
    keys_allowed = ('q', 'p')
elif rectangles_used_list[0] == "both_bottom":
    keys_allowed = ('z', 'm')
elif rectangles_used_list[0] == "lefttop_rightbottom":
    keys_allowed = ('q', 'm')
elif rectangles_used_list[0] == "righttop_leftbottom":
    keys_allowed = ('z', 'p')

1 Like