EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Appendix C: Keyboard Keys and Key Code Values

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
781
C
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 Key code ASCII key code
A65 65
B66 66

Table of Contents

Related product manuals