# How not to put a linebreak into textfield after pressing ENTER

**URL:** <https://forum.kirupa.com/t/how-not-to-put-a-linebreak-into-textfield-after-pressing-enter/241219>\
**Category:** flash\
**Created:** [October 11, 2007, 3:22am UTC](https://forum.kirupa.com/t/how-not-to-put-a-linebreak-into-textfield-after-pressing-enter/241219 "2007-10-11T03:22:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Poco](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@Poco](https://forum.kirupa.com/u/Poco)\
**Post date:** [October 11, 2007, 3:22am UTC](https://forum.kirupa.com/t/how-not-to-put-a-linebreak-into-textfield-after-pressing-enter/241219/1 "2007-10-11T03:22:13Z")

</div>

Hi guys,  
The point of my question looks quite easy but I can’t find an answer for it. I have an input textfield (or textarea) and after pressing ENTER key, the text should be sent. That works without problems, the problem is that with multiline textfield pressing ENTER puts a linebreak, so the cursor jumps to the “2nd line” in the textfield. Does anybody know how to avoid this? The code I am using so far:

```auto

var keySend:Object = new Object();
function onEnterDown() {
    if (Key.isDown(Key.ENTER)) {
        chat_so.data.textmessage = message_ta.text+newline;
        chat_so.data.username = username;
        chat_ta.text += username+": "+message_ta.text+newline;
        message_ta.text = "";
    }
}

keySend.onKeyDown = onEnterDown;
message_ta.onSetFocus = function(){
    Key.addListener(keySend);
}
message_ta.onKillFocus = function(){
    Key.removeListener(keySend);
}

```

Thanks a lot for any advice!

P.
