Using Enter key & mouse to call function

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



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

};


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

Instead of using functions you can just do this…

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

That worked thanks…

No problem, I am glad I could help :slight_smile:

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.



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…

Try changing & to &&

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

Alright, I did this and it worked great :slight_smile:

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 :slight_smile:

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…

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

(works only in MX)

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

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

I am glad everything works for you :slight_smile: