Getting keyboard input (text) from the participant

I’m showing videos and want to get text input from the participant after the video ends.
I found visual.TextBox object. And indeed it draws a white box on the screen.

To get the keyboard input I used the code from this answer: Text input field with PsychoPy 3.1.2 - #2 by dvbridges
but I can’t make it work. I get an error on key_resp.keys = It looks like the experiment terminates before I manage to press a single button.

To be more specific: I want the participant to input several word that should be saved as one string and the sting should be saved after the participant hits enter.

For now, I came up with this:

resp = event.BuilderKeyResponse()
continueRoutine = True
while continueRoutine:
    if resp.status == STARTED:
        keys = event.getKeys()
        if resp.keys[-1] == 'return':
            continueRoutine = False

But it’s hanging

Here is what I came up with:

    continueRoutine = True
    response = []
    while continueRoutine:
        keys = event.waitKeys()
        if keys[-1] == 'return':
            continueRoutine = False

    response = response[:-1]
    response = [item for sublist in response for item in sublist]
    response = "".join(response)```