Key presses aren't cleared correctly

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): win10
PsychoPy version (e.g. 1.84.x): 2020.1.3 builder
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:

In the FillerTask routine, I created a response box, in which any number I press will show up.

What did you try to make it work?:

I added a customized code:
Begin routine:
event.clearEvents()
kbFiller1 = keyboard.Keyboard()
textFill = ‘’
kbFiller1.start()

Each frame:
keysQ1 = kbFiller1.getKeys([‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘0’,‘backspace’], waitRelease = False)
for thisKey in keysQ1:
if thisKey == ‘backspace’:
textFill = textFill[:-1]
elif thisKey in [‘1’,‘2’,‘3’,‘4’,‘5’,‘6’,‘7’,‘8’,‘9’,‘0’]:
textFill += thisKey.name
textFeedback.setText(textFill) # Set new text on screen

What specifically went wrong when you tried that?:

In the previous routine (FillerInstr) in which I need to press space to continue, if I press any number before pressing space, the number will also show up on the next screen.

Include pasted full error message if possible. “That didn’t work” is not enough information.