# Using Enter key & mouse to call function

**URL:** <https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977>\
**Category:** flash\
**Created:** [December 2, 2002, 5:32am UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977 "2002-12-02T05:32:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![byis](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@byis](https://forum.kirupa.com/u/byis)\
**Post date:** [December 2, 2002, 5:32am UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/1 "2002-12-02T05:32:22Z")

</div>

How would I enable the enter key to work with the function listed below as well as mouse release…

```php

enter_btn.onRelease = function() {
	
	output1 = //calculations go here//

};

```

Not use to using key responses in junction with functions…Thanks for the help!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 2, 2002, 5:42am UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/2 "2002-12-02T05:42:50Z")

</div>

Instead of using functions you can just do this…

```auto
onClipEvent (enterFrame) {
	if (Key.isDown(Key.ENTER)) {
		trace("Enter Button Pressed");
	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 2, 2002, 9:24pm UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/3 "2002-12-02T21:24:35Z")

</div>

That worked thanks…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 2, 2002, 9:28pm UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/4 "2002-12-02T21:28:39Z")

</div>

No problem, I am glad I could help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 4, 2002, 12:53pm UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/5 "2002-12-04T12:53:00Z")

</div>

Lost, you can probably help me with this. Trying make so that when you hold down both the CTRL and Z keys clears input field.

```auto

Doesnt Work:
if (Key.isDown(Key.CONTROL & Key.Z)) {
	input1 = spaces;
};

Also Doesnt work:
Doesnt Work:
if (Key.isDown(Key.CONTROL & Key."Z")) {
	input1 = spaces;
};

This Works:
if (Key.isDown(Key.CONTROL & Key.SHIFT)) {
	input1 = spaces;
};

```

Thanks…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 4, 2002, 4:42pm UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/6 "2002-12-04T16:42:24Z")

</div>

Try changing & to &&

&& is a boolean value saying if this statement and this statement are true then do this.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 4, 2002, 4:59pm UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/7 "2002-12-04T16:59:52Z")

</div>

Alright, I did this and it worked great 🙂

```auto
onClipEvent (enterFrame) {
	if (Key.isDown(Key.CONTROL) && Key.isDown(90)) {
		trace("CTRL+Z has been pressed");
	}
}

```

90 is the code used for the letter “z” (lowercase). You need 2 Key.isDown statements because if you use && inside the first isDown then it still works if just z is pressed… I don’t think you want that 🙂

If you ever need to find out what letter is what code or whatnot, I wrote up with this script that I refer back to all the time when I need to find out.

Just put this in Frame 1 and you are done…

```auto
keyListener = new Object();
keyListener.onKeyDown = function() {
	keypressed = Key.getCode();
	trace(keypressed);
};
Key.addListener(keyListener);

```

(works only in MX)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 5, 2002, 2:17am UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/8 "2002-12-05T02:17:20Z")

</div>

Thanks Lost that worked great. That script will be nice to have…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 6, 2002, 1:51am UTC](https://forum.kirupa.com/t/using-enter-key-mouse-to-call-function/8977/9 "2002-12-06T01:51:28Z")

</div>

Yeah, the getCode script definitely comes in handy when you just can’t put your finger on the code of the character you want 🙂

I am glad everything works for you 🙂
