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
* Keys on the numeric keypad
* Function keys
* Other keys
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, draw a text field on the Stage. Select Input Text from the Text Type drop-down menu in the Properties panel, and click the Show border around text option. Then paste the following ActionScript code into the actions panel for the current Frame on the Timeline:
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
For additional key code and ASCII values, use the ActionScript at the beginning of this appendix and press the desired key to trace its key code.
To know key value of every key go to this link
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000520.html
No comments:
Post a Comment