
Key.getCode() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
560
|
ActionScript Language Reference
See Also
Key.getCode( ), Key.isDown( ); Appendix B
Key.getCode() Method
returns the keycode of the last key pressed
Flash 5
Key.getCode()
Returns
An integer representing the keycode of the last key pressed.
Description
The getCode( ) method returns the keycode of the last key that was pressed; the keycode is
an arbitrary number representing the physical location of a key on the keyboard. On non-
Windows operating systems, the native keycode system is translated automatically by Flash
to the Windows equivalent, so getCode( ) provides a cross-platform means of detecting
specific physical keys. The getCode( ) method can also be used to differentiate between two
keys with the same ASCII value. For example, it can differentiate between the 8 key on the
main keyboard and the 8 key on the numeric keypad, whereas getAscii( ) cannot. However,
getCode( ) cannot differentiate between upper- and lowercase letters (for example, A and a
use the same keycode because they are produced using the same key). Nor does it detect
modifier keys such as the Ctrl or Shift key.
Many common keycode values are available as properties of the Key object, as shown in
Table R-8 under the Description for the Key object. To determine the keycode of a partic-
ular key, ...