# Getting keyboard input (text) from the participant

**URL:** <https://discourse.psychopy.org/t/getting-keyboard-input-text-from-the-participant/31612>\
**Category:** Coding\
**Created:** [October 28, 2022, 2:51pm UTC](https://discourse.psychopy.org/t/getting-keyboard-input-text-from-the-participant/31612 "2022-10-28T14:51:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nastialado](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/nastialado/32/34029_2.png) [@nastialado](https://discourse.psychopy.org/u/nastialado)\
**Post date:** [October 28, 2022, 2:51pm UTC](https://discourse.psychopy.org/t/getting-keyboard-input-text-from-the-participant/31612/1 "2022-10-28T14:51:43Z")

</div>

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](https://discourse.psychopy.org/t/text-input-field-with-psychopy-3-1-2/8401/2)  
but I can’t make it work. I get an error on `key_resp.keys = theseKeys.name`. 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:

```auto
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

---

<div class="post-metadata">

**Author:** ![nastialado](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/nastialado/32/34029_2.png) [@nastialado](https://discourse.psychopy.org/u/nastialado)\
**Post date:** [November 1, 2022, 6:41pm UTC](https://discourse.psychopy.org/t/getting-keyboard-input-text-from-the-participant/31612/2 "2022-11-01T18:41:57Z")

</div>

Here is what I came up with:

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

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