Question

Here's my current code:

if (Key.isDown(Key.UP)) {
 //do stuff
}

What I want to do, is to detect if user presses a button. My code atm just detects if it's pressed down continueusly. Is there a way to detect when user only presses it down, doesn't hold it down?

And please, no AS3 answers here.

Martti Laine

Was it helpful?

Solution

You can create a listener to respond to the onKeyUp event, like this:

var myListener:Object = new Object();

myListener.onKeyUp = function () {
    //do stuff
}
Key.addListener(myListener);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top