views:

142

answers:

1

Hello

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

A: 

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);
Richard Inglis