Flash Lite 2.x and 3.0 ActionScript Language Reference

isDown (Key.isDown method)

public static isDown(code:Number) : Boolean

Returns true if the key specified in code is pressed; false otherwise.

Parameters

code:Number - The key code value assigned to a specific key or a Key class property associated with a specific key.

Returns

Boolean - The value true if the key specified in code is pressed; false otherwise.

Example

The following script lets the user control the location of a movie clip (car_mc):

car_mc.onEnterFrame = function() {
 if (Key.isDown(Key.RIGHT)) {
 this._x += 10;
 } else if (Key.isDown(Key.LEFT)) {
 this._x -= 10;
 }
};