# Textbox (and textbox.text output) includes carry over string from other components/routines

**URL:** <https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829>\
**Category:** Builder\
**Created:** [February 26, 2021, 1:33pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829 "2021-02-26T13:33:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/martin/32/6250_2.png) [@Martin](https://discourse.psychopy.org/u/Martin)\
**Post date:** [February 26, 2021, 1:33pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/1 "2021-02-26T13:33:25Z")

</div>

**OS** : Win10  
**PsychoPy version** : 2021.1.2  
**Standard Standalone? (y/n)** Y

Hi, trying the new amazing textbox component. It seems to work as I wanted, i.e., participant enters a short text there (editable). However, in the output .csv file, the textbox.text column includes some contents of the keyboard responses from the previous routines/key\_resp components (e.g., if previous routine requires pressing ENTER in order to terminate, then an empty line would appear in the next routine in the textbox component). Has this been addressed somewhere?

Thank you!

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [February 26, 2021, 4:00pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/2 "2021-02-26T16:00:24Z")

</div>

Just to be clear, is this only for when a key is still held down when the next routine starts? For example, if you type a bunch of characters in one textbox, those characters aren’t then all recorded for the next one?

I think we may be able to fix that, but I’d have to check - it would probably be something like what we do for Mouse and Button where we can check whether a button press is a new press, so only new keypresses are registered.

---

<div class="post-metadata">

**Author:** ![Martin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/martin/32/6250_2.png) [@Martin](https://discourse.psychopy.org/u/Martin)\
**Post date:** [February 26, 2021, 4:50pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/3 "2021-02-26T16:50:11Z")

</div>

Here is the flow: the trial (routine) ends by a keypress, if it is “return”, then the textbox in the subsequent routine (Text) would (sometimes) have first line empty (as if u pressed enter). Or, if it is a letter, then the routine’s textbox element starts with this letter filled in. Sometimes it seems that the empty lines / spaces are accumulating, but I did not have time to check it in a systematic way. Anyway, I resolved this temporarily by requiring “tab” keypress to end the routine (i.e., for transitions). Since “tab” does not fill in any “content”, there is no “carry over” (except the fact that sometimes there is additional empty space, " ", in the text, though). Thank you for checking this out. Best, M.

 ![obrázok](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/2/8/284130da39fa2bc0da7d77931462fa79ebc39472.png)

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [March 1, 2021, 10:16am UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/4 "2021-03-01T10:16:46Z")

</div>

Ah yes that makes sense - it’s probably that the keypress continues into the first frame of the next routine, so the Textbox is picking it up as a new press. I’ll look into adding something at the start routine code for TextBox to make sure it only accepts new presses. Thanks for catching this!

---

<div class="post-metadata">

**Author:** ![ezaleznik](https://avatars.discourse-cdn.com/v4/letter/e/ed8c4c/32.png) [@ezaleznik](https://discourse.psychopy.org/u/ezaleznik)\
**Post date:** [March 8, 2021, 5:06pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/5 "2021-03-08T17:06:11Z")

</div>

I’m having the same issue (sorry if we don’t like “bumping” threads here, but this was a recent thread and the same concern).

I want participants to type their answer into a textbox and hit “return” to submit. I haven’t run into any issues where their answer carried over (they’re not responding that quickly) but the “return” does, causing the location of the textbox input to jump around.

These didn’t work, but what I tried was:

- Briefly delaying the start of the textbox stimulus
- Adding a code for “Begin routine” to set textbox.text it to " "

Beyond those, I’m not sure how to tell it to only accept new presses. It’s not a huge deal, but it’s a little distracting and maybe a concern when working across different hardware. Thank you for your advice!

---

<div class="post-metadata">

**Author:** ![fiqbal098](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fiqbal098](https://discourse.psychopy.org/u/fiqbal098)\
**Post date:** [April 14, 2021, 12:33am UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/7 "2021-04-14T00:33:53Z")

</div>

Hi,

Do you mind posting the specific code you had used to fix this error? I am struggling a bit with inputting your proposed solutions…Thank you in advance 🙂

---

<div class="post-metadata">

**Author:** ![Reiner](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@Reiner](https://discourse.psychopy.org/u/Reiner)\
**Post date:** [April 28, 2021, 1:46pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/8 "2021-04-28T13:46:17Z")

</div>

I had the same problem and I am using an easy workaround.  
You can insert a single line of code like:

GetMailString.text =""  
at the beginning of the routinne,  
where “GetMailString” is the name of my textbox component.

---

<div class="post-metadata">

**Author:** ![Reiner](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@Reiner](https://discourse.psychopy.org/u/Reiner)\
**Post date:** [April 28, 2021, 1:48pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/9 "2021-04-28T13:48:02Z")

</div>

I have a request ( not sure where else to put it ).

The “editable” is easy to overlook for people that only get into PsychoPy occasionally.  
Personally I would prefer if the checkbox is replaced with a drop-down on the right ( where all drop-downs are ) just saying “editable” “constant” as options.

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [April 28, 2021, 2:11pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/10 "2021-04-28T14:11:37Z")

</div>

I think editable will work with both constant and each repeat but I agree than it might make sense to have it in the constant/each repeat/each frame dropdown to clarify what combinations are sensible.

What do you think @TParsons ?

---

<div class="post-metadata">

**Author:** ![Reiner](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@Reiner](https://discourse.psychopy.org/u/Reiner)\
**Post date:** [April 28, 2021, 5:49pm UTC](https://discourse.psychopy.org/t/textbox-and-textbox-text-output-includes-carry-over-string-from-other-components-routines/20829/11 "2021-04-28T17:49:46Z")

</div>

Thanks wakecarter,  
my desire is to make it larger and in line with the other options.  
The “Constant” I used intended to say “not editable” :-), not about the specific wording.
