14Built-in Classes: The Key Class

The Key Class

The Key Class is used to capture keyboard input. Although some applications may only make use of the mouse, most will get some input from the user via the keyboard.

The Key Class has a number of useful methods, including:

getCode( ) Returns the keyboard code of the latest key press
getAscii( ) Returns the ASCII code of the latest key press
isDown(keycode:Number) Returns true if the specified key is down
isToggled(keycode:Number) Returns true if the specified modifier key is down
addListener(listener:Object) Registers an object to receive Key events
removeListener(listener:Object) Un-registers an object as a Key listener

There are essentially three strategies for capturing keyboard ...

Get Understanding Macromedia Flash 8 ActionScript 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.