isDown (Key.isDown method)

public static isDown(code:Number) : Boolean

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.

A Flash application can only monitor keyboard events that occur within its focus. A Flash application cannot detect keyboard events in another application.

Availability: ActionScript 1.0; Flash Player 5

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 keycode is pressed; false otherwise.

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;
 }
};

Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001763.html