# Form and enter key

**URL:** <https://forum.kirupa.com/t/form-and-enter-key/201595>\
**Category:** Uncategorized\
**Created:** [September 22, 2006, 7:41pm UTC](https://forum.kirupa.com/t/form-and-enter-key/201595 "2006-09-22T19:41:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashleyppg](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@ashleyppg](https://forum.kirupa.com/u/ashleyppg)\
**Post date:** [September 22, 2006, 7:41pm UTC](https://forum.kirupa.com/t/form-and-enter-key/201595/1 "2006-09-22T19:41:55Z")

</div>

I need to be able to press the enter key for my form to work. I got this code from another thread:

```auto
 Key.addListener(myListener);
	EnterKeyListener = new Object();
	EnterKeyListener.onKeyDown = function() {
		if (Key.getCode() == "13") {
			//code
		}
	};
	Key.addListener(EnterKeyListener);

and then I put it on my submit button like this:

on (release, keyPress "<Enter>") {
	mess = "Sign in please!";
	if (username == "CSI555") {
		mess = "Invalid password";
	}
	if (password == "CSI555") {
		mess = "Invalid username";
	}
	if (username == "CSI555" & password == "CSI555") {
		gotoAndPlay("administrativetools");
	}
	myListener = new Object();
	myListener.onKeyDown = function() {
		if (Key.isDown(Key.ENTER)) {
			//code
		}
	};
	Key.addListener(myListener);
	EnterKeyListener = new Object();
	EnterKeyListener.onKeyDown = function() {
		if (Key.getCode() == "13") {
			//code
		}
	};
	Key.addListener(EnterKeyListener);
}

```

but it doesn’t work. I’m not sure where to put it, or how to make it work. Please help!!

Thank you.  
ashley
