The keyboard response from the previous routine is carried over into the textbox of the next routine

Description of the problem:

I’m currently facing an issue with the Textbox component in PsychoPy where it seems to retain keys pressed in the previous routine. This issue occurs when I transition from one routine to another; the keys that were pressed in the first routine are somehow carried over to the next, affecting the input in the Textbox in the subsequent routine. For example, if the number ‘4’ was pressed in the previous routine, it automatically appears in the Textbox of the next routine without any key being pressed.

I have attempted to resolve this by adding a code component to the routine containing the Textbox. In the ‘Begin Routine’ section, I included the code textbox.text = '' , hoping it would clear any previous inputs. Unfortunately, this approach hasn’t been effective.

Has anyone else encountered this problem? If so, how were you able to resolve it? Any suggestions on how to clear the key buffer or reset the Textbox state between routines would be greatly appreciated.

Thanks in advance for your help!

I am using Builder, PsychoPy 2022.2.5 on Win11.

Thanks for helping!

Is your code component above the textbox?

Yes, the code is at the top. I even tried to put the code component at the bottom of the previous routine, but it didn’t work.

In the textbox component itself try setting the text to reset each repeat. I think that’s what I usually do.

I think, from the very beginning, I did what you said. But there’s the problem I’m talking about.

Do you have an ISI or does the routine restart as soon as the previous one has ended?

Have you tried textbox.refresh() in Begin Routine?

Textbox has improved a lot since 2022 so you could try installing the latest version of PsychoPy