APPENDIX C
Keyboard Keys and Key
Code Values
The following tables list all the keys on a standard keyboard and the corresponding key code
values and ASCII key code values that are used to identify the keys in ActionScript:
"Letters A to Z and standard numbers 0 to 9" on page 781
"Keys on the numeric keypad" on page 784
"Function keys" on page 784
"Other keys" on page 785
You can use key constants to intercept the built-in behavior of keypresses. For more
information on the on() handler, see on handler in the ActionScript 2.0 Language
Reference. To capture key code values and ASCII key code values using a SWF file and key
presses, you can use the following ActionScript code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
trace("DOWN -> Code: " + Key.getCode() + "\tACSII: " + Key.getAscii() +
"\tKey: " + chr(Key.getAscii()));
};
Key.addListener(keyListener);
For more information on the Key class, see Key in ActionScript 2.0 Language Reference.
To trap keys when you test a SWF file in the authoring environment (Control > Test Movie),
make sure that you select Control > Disable Keyboard Shortcuts.
Letters A to Z and standard numbers 0 to 9
The following table lists the keys on a standard keyboard for the letters A to Z and the
numbers 0 to 9, with the corresponding key code values that are used to identify the keys
in ActionScript:
Letter or number key
A
B
Key code
65
66
ASCII key code
65
66
C
781
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?