URL of experiment: https://pavlovia.org/MJB/libet
Description of the problem:
I have 2 unrelated problems with the above experiment:
Firstly, the JS version appears to only save data from the first 2 conditions it runs, not the final 3rd one. The local python version saves all. There is no error and I am not sure what is going on.
Secondly, I have a code component that drives some keyboard entry and should allow only target answers between 0 and 60.
The Python code is this and works exactly as intended:
If the subject presses RETURN after having entered anything other than a number between 0 and 60, the entry field resets. If the number is between 0 and 60, the routine ends (and the data is stored)
keys = event.getKeys(keyList=['0','1','2','3','4','5','6','7','8','9','0','backspace','return'])
if len(keys):
if 'backspace' in keys:
text.text = ''
estimateVale = ''
handOri = 90
elif 'return' in keys:
if 0 <= estimateVale <= 60:
continueRoutine = False
else:
text.text = ''
estimateVale = ''
handOri = 90
print (estimateVale)
else:
text.text = text.text + keys[0]
estimateVale = float(text.text)
handOri = -estimateVale * 6 + 90
The JS translation is below and when I run online, it allows me to enter numbers greater than 60 and I can still press return to move on
let theseKeys = psychoJS.eventManager.getKeys({keyList:['0','1','2','3','4','5','6','7','8','9','0','backspace','return']});
if (theseKeys.length > 0) {
textAdd = theseKeys[theseKeys.length-1];
}
if (textAdd === 'return') {
if (0 <= estimateVale <= 60) {
continueRoutine = false;
textAdd = undefined;
} else
text.text = '';
estimateVale = '';
handOri = 90;
} else if (textAdd === 'backspace') {
text.text = '';
textAdd = undefined;
estimateVale = '';
handOri = 90;
} else if (textAdd !== undefined) {
text.text = text.text + textAdd;
estimateVale = Number.parseFloat(text.text);
handOri = ((-estimateVale * 6) + 90);
textAdd = undefined;
}