User Guide
Key.isDown() 357
Key.isDown()
Availability
Flash Player 5.
Usage
Key.isDown(keycode:Number) : Boolean
Parameters
keycode
The key code value assigned to a specific key or a Key class property associated with a
specific key. To match the returned key code value with the key on a standard keyboard, see
Appendix C, “Keyboard Keys and Key Code Values” in Using ActionScript in Flash.
Returns
A Boolean value.
Description
Method: returns true if the key specified in keycode is pressed; false otherwise. On the
Macintosh, the key code values for the Caps Lock and Num Lock keys are identical.
Example
The following script lets the user control a movie clip’s (car_mc) location:
car_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x += 10;
} else if (Key.isDown(Key.LEFT)) {
this._x -= 10;
}
};