# Hit ENTER to have an Action

**URL:** <https://forum.kirupa.com/t/hit-enter-to-have-an-action/275702>\
**Category:** flash\
**Created:** [November 17, 2008, 6:51pm UTC](https://forum.kirupa.com/t/hit-enter-to-have-an-action/275702 "2008-11-17T18:51:18Z")\
**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:51pm UTC](https://forum.kirupa.com/t/hit-enter-to-have-an-action/275702/1 "2008-11-17T18:51:18Z")

</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.
