View comments | RSS feed

CAPSLOCK (Key.CAPSLOCK property)

public static CAPSLOCK : Number

The key code value for the Caps Lock key (20).

Availability: ActionScript 1.0; Flash Player 5

Example

The following example creates a new listener object and defines a function for onKeyDown. The last line uses addListener() to register the listener with the Key object so that it can receive notification from the key down event.

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    if (Key.isDown(Key.CAPSLOCK)) {
    trace("you pressed the Caps Lock key.");
    trace("\tCaps Lock == "+Key.isToggled(Key.CAPSLOCK));
    }
};
Key.addListener(keyListener);

Information is displayed in the Output panel when you press the Caps Lock key. The Output panel displays either true or false, depending on whether the Caps Lock key is activated using the isToggled method.


Flash CS3


Comments


gaw.in said on Jun 10, 2007 at 6:01 PM :
// This will show the current status of the CAPS LOCK key, also when
turned off, using a onKeyUp event.

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.CAPSLOCK)) {
trace("Caps Lock == "+Key.isToggled(Key.CAPSLOCK));
}
};
keyListener.onKeyUp = function(){
if (Key.getCode() == Key.CAPSLOCK) {
trace("Caps Lock == "+Key.isToggled(Key.CAPSLOCK));
}
}
Key.addListener(keyListener);

 

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

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