| Reference | Downloads | Github

The routine to get typed response does not show up at all and is skipped in Pavlovia

URL of experiment: exp2_nn [PsychoPy]

Description of the problem: Hello everyone!

I am trying to get typed responses several times from participants in an online experiment. But although it works fine once, the other trials which include the typed response are skipped and do not even show up on screen, like they do not exist.
I used a code component to get typed responses inspired from this link
and my code for begin routine:

this for each frame and

for end routine.
I have put the typed response trial after the consent form but you probably will not see it as it is exactly the problem.
As my project is freezed now, any help is extremely appreciated.
I also put my experiment file here if you wanted to take a look.

Thank you in advance

This is an example of why I recommend using Auto code translation as much as possible. Your } bracket on line 4 of Each Routine should be moved to the bottom of the code so it encloses the other statements.

I tried what you said but it did not change anything. Still the experiment jumps over my typed response routines.
Besides, the same code works in two of my routines but does not work in other routines. It is very weird!

let theseKeys = psychoJS.eventManager.getKeys();
if (theseKeys.length > 0) { // at least one key was pressed
    textAdd = theseKeys[theseKeys.length - 1];

    if (textAdd === 'return') {
        textAdd = ''; // Add nothing
        continueRoutine = false; // End routine (if that is what you want)
    } else if (textAdd === 'space') {
        textAdd = ' '; // Add a space
    } else if (textAdd === 'backspace') {
        text_9.text = text_9.text.slice(0, -1);
        textAdd = undefined;
    } else if (['lshift', 'rshift'].includes(textAdd)) {
        modify = true;
    } else if (textAdd !== undefined) {
        if (modify) {
            text_9.text = text_9.text + textAdd.toUpperCase();
            modify = false;
        } else {
            text_9.text = text_9.text + textAdd
        textAdd = undefined;

When I use auto translation I got the error:

Unfortunately we encountered the following error:

  • TypeError: Cannot read property ‘clearEvents’ of undefined

Try to run the experiment again. If the error persists, contact the experiment designer.
Which as I searched the solution for it is to change all events in JS to psychoJS.eventManager but in auto translation change in the js code is not possible.

Now I remember the reason why I used both instead of auto translation in the first place was the same error

Have a look at my crib sheet. If you define certain variables or import PolyFill in “code_JS” then you don’t need to make these manual translations.

You may also find my Free Recall demo useful (see my online demos) though that instance is probably more complicated than you need.