# Input field action on Press ENTER

**URL:** <https://forum.kirupa.com/t/input-field-action-on-press-enter/275703>\
**Category:** Uncategorized\
**Created:** [November 17, 2008, 6:52pm UTC](https://forum.kirupa.com/t/input-field-action-on-press-enter/275703 "2008-11-17T18:52:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhikumar](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@abhikumar](https://forum.kirupa.com/u/abhikumar)\
**Post date:** [November 17, 2008, 6:52pm UTC](https://forum.kirupa.com/t/input-field-action-on-press-enter/275703/1 "2008-11-17T18:52:46Z")

</div>

Hello,

For an input field - i need to have some action when user enters something in the input field and hit ENTER.

I am using this: but with this user can hit enter anywhere on the screen and get the action- i need to have it only when user selects the input field.

```auto
myNewObject = new Object();
myNewObject.onKeyDown = function() {
 if (Key.isDown(Key.ENTER)) {
     trace("do something")
 }
};
Key.addListener(myNewObject);

```

PLEASE HELP.
