ActionScript Guide and Resources

Ascii to Flash ActionScript Key Codes

Ascii String Code
8 (backspace) 8
13 (enter) 13
0 (shift) 16
0 (ctrl) 17
0 (alt) 18
0 (capslock) 20
27 (esc) 27
32 (space) 32

w/o shift key

48 0 48
49 1 49
50 2 50
51 3 51
52 4 52
53 5 53
54 6 54
55 7 55
56 8 56
57 9 57
97 a 65
98 b 66
99 c 67
100 d 68
101 e 69
102 f 70
103 g 71
104 h 72
105 i 73
106 j 74
107 k 75
108 l 76
109 m 77
110 n 78
111 o 79
112 p 80
113 q 81
114 r 82
115 s 83
116 t 84
117 u 85
118 v 86
119 w 87
120 x 88
121 y 89
122 z 90
59 ; 186
61 = 187
44 , 188
45 - 189
46 . 190
47 / 191
96 ` 192
91 [ 219
92 \ 220
93 ] 221
39 ' 222

w/ shift key

41 ) 48
33 ! 49
64 @ 50
35 # 51
36 $ 52
37 % 53
94 ^ 54
38 & 55
42 * 56
40 ( 57
65 A 65
66 B 66
67 C 67
68 D 68
69 E 69
70 F 70
71 G 71
72 H 72
73 I 73
74 J 74
75 K 75
76 L 76
77 M 77
78 N 78
79 O 79
80 P 80
81 Q 81
82 R 82
83 S 83
84 T 84
85 U 85
86 V 86
87 W 87
88 X 88
89 Y 89
90 Z 90
58 : 186
43 + 187
60 < 188
95 _ 189
62 > 190
63 ? 191
126 ~ 192
123 { 219
124 | 220
125 } 221
34 " 222

Keypad Keys w/numlock on

13 (enter) 13
48 0 96
49 1 97
50 2 98
51 3 99
52 4 100
53 5 101
54 6 102
55 7 103
56 8 104
57 9 105
42 * 106
43 + 107
45 - 109
46 . 110
47 / 111

Keypad Keys w/numlock off

13 (enter) 13
0 (PgUp) 33
0 (PgDown) 34
0 (End) 35
0 (Home) 36
0 (left arrow) 37
0 (up arrow) 38
0 (right arrow) 39
0 (down arrow) 40
0 (Ins) 45
127 (Delete) 46
42 * 106
43 + 107
45 - 109
47 / 111

Side Keys

0 (Pause) 19
0 (PageUp) 33
0 (PageDown) 34
0 (End) 35
0 (Home) 36
0 (Ins) 45
127 (Delete) 46
0 (ScrollLock) 145

Arrow Keys

0 (left) 37
0 (up) 38
0 (right) 39
0 (down) 40

Function Keys

0 (F1) 112
0 (F2) 113
0 (F3) 114
0 (F4) 115
0 (F5) 116
0 (F6) 117
0 (F7) 118
0 (F8) 119
0 (F9) 120
0 (F10) 121
0 (F11) 122
0 (F12) 123

Key codes and character codes

You can access the keyCode and charCode properties of a keyboard event to determine what key was pressed and then trigger other actions. The keyCode property is a numeric value that corresponds to the value of a key on the keyboard. The charCode property is the numeric value of that key in the current character set. (The default character set is UTF-8, which supports ASCII.)

The primary difference between the key code and character values is that a key code value represents a particular key on the keyboard (the 1 on a keypad is different than the 1 in the top row, but the key that generates 1 and the key that generates ! are the same key) and the character value represents a particular character (the R and r characters are different).

Note: For the mappings between keys and their character code values in ASCII, see the flash.ui.Keyboard class in the ActionScript 3.0 Reference for the Adobe Flash Platform.

The mappings between keys and their key codes is dependent on the device and the operating system. For this reason, you should not use key mappings to trigger actions. Instead, you should use the predefined constant values provided by the Keyboard class to reference the appropriate keyCode properties. For example, instead of using the key mapping for the Shift key, use the Keyboard.SHIFT constant (as shown in the preceding code sample).

ActionScript 3.0 code see http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d01.html 


http://www.drpeterjones.com/colorcalc/