I’ve noticed the same problem. Running in version 2023.1.3 seems to fix the issue, but it recurs if setting the experiment to run in any more recent version. I’m guessing that it’s a bug (or other change in keypress handling) that must have been introduced version 2023.2.0.
I’ve been using the following code, that IIRC I adapted from one of Wakefield Morys-Carter’s demos. It’s run well for three years previously, but from 2023.2.0 onwards the backspace function no longer works. IDK if it’s relevant, but I’m using a Mac (where the ‘backspace’ key is labeled as ‘delete’ and thus might have a technically different mapping from PC backspace keys), so maybe it could be a problem with how the PsychoJS now handles Mac keyboards.
let theseKeys = psychoJS.eventManager.getKeys({keyList:['return','space','backspace','lshift', 'rshift','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']});
if (theseKeys.length > 0) { // at least one key was pressed
textAdd = theseKeys[theseKeys.length-1];
}
if (textAdd === 'return') {
textAdd = ''; // Add nothing
if (text.text.length > 0) {
continueRoutine = false; // End routine (if that is what you want)
}
} else if (textAdd === 'space') {
if (text.text.length > 0) {
textAdd = ' '; // Add a space
} else {
textAdd = ''; // Add nothing
}
} else if (textAdd === 'backspace') {
text.text = text.text.slice(0, -1);
textAdd = undefined;
} else if (['lshift', 'rshift'].includes(textAdd)) {
modify = true;
} else if (textAdd !== undefined) {
if (modify) {
text.text = text.text + textAdd.toUpperCase();
modify = false;
} else {
text.text = text.text + textAdd
}
textAdd = undefined;
}