# Small question on Key.ENTER handling

**URL:** <https://forum.kirupa.com/t/small-question-on-key-enter-handling/71539>\
**Category:** Uncategorized\
**Created:** [November 26, 2004, 7:43am UTC](https://forum.kirupa.com/t/small-question-on-key-enter-handling/71539 "2004-11-26T07:43:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eirche](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@eirche](https://forum.kirupa.com/u/eirche)\
**Post date:** [November 26, 2004, 7:43am UTC](https://forum.kirupa.com/t/small-question-on-key-enter-handling/71539/1 "2004-11-26T07:43:42Z")

</div>

```auto

// msg_box_txt is a TextField for user input
// by hitting ENTER, it sends msg_box_txt.text

var my_listener:Object = new Object();
my_listener.onKeyDown = function() {
	if (Key.getCode() == Key.ENTER) {
		//sends off msg_box_txt.text
		msg_box_txt.text = "";
	}
};
msg_box_txt.onSetFocus = function() {
	Key.addListener(my_listener);
};
msg_box_txt.onKillFocus = function() {
	Key.removeListener(my_listener);
};

```

msg\_box\_txt should be cleared, empty, after hitting ENTER. the problem that it contains one empty line, and the cursor is at beginning of the second line. how can this be fixed??
