I have a PsychoPy task where participants need to make a choice between two boxes. One box "opens" by pushing the right arrow key three times. The other "opens" by pushing the left arrow key two times. By "opens" I mean that the task advances to the next routine. I have successfully coded this using Python, but to run it online, I need to use JavaScript. Nothing I've tried has worked. Here is the Python code:
if key_resp_14.keys == ['left', 'left']:
continueRoutine = False
elif key_resp_14.keys == ['right', 'right', 'right']:
continueRoutine = False
elif key_resp_14.keys == ['left', 'right']:
key_resp_14.keys = []
theseKeys = key_resp_14.getKeys(keyList=['left', 'right'])
elif key_resp_14.keys == ['right', 'right', 'left']:
key_resp_14.keys = []
theseKeys = key_resp_14.getKeys(keyList=['left', 'right'])
elif key_resp_14.keys == ['right', 'left']:
key_resp_14.keys = []
theseKeys = key_resp_14.getKeys(keyList=['left', 'right'])
I've tried using essentially the same code in JS:
if (key_resp_14.keys === ["right","right","right"]) {
continueRoutine = false;
}
if (key_resp_14.keys === ["left","left"]) {
continueRoutine = false;
}
etc.
I've tried various versions of the above code with no success. I've also tried creating a variable that is a vector and pushing the info from key_resp_14.keys into that vector. When I do that, I get every keystroke from the start of the task (key_resp_1.keys all the way through key_resp_14.keys), instead of just the keystrokes from key_resp_14.keys. Any help or suggestions are greatly appreciated.