Actionscript 2: How to detect a key?
-
20-09-2019 - |
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
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