Flash Lite 2.x and 3.0 ActionScript Language Reference

ENTER (Key.ENTER property)

public static ENTER : Number

The key code value for the Enter key (13)..

Example

The following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. The car_mc instance stops when you press Enter and delete the onEnterFrame event.

var DISTANCE:Number = 5;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    switch (Key.getCode()) {
    case Key.LEFT :
    car_mc.onEnterFrame = function() {
        this._x -= DISTANCE;
    };
    break;
    case Key.UP :
    car_mc.onEnterFrame = function() {
        this._y -= DISTANCE;
    };
    break;
    case Key.RIGHT :
    car_mc.onEnterFrame = function() {
        this._x += DISTANCE;
    };
    break;
    case Key.DOWN :
    car_mc.onEnterFrame = function() {
        this._y += DISTANCE;
    };
    break;
    case Key.ENTER :
    delete car_mc.onEnterFrame;
    break;
    }
};
Key.addListener(keyListener);

When using this example, make sure that you select Control > Disable Keyboard Shortcuts in the test environment.