June 29 2008

AS 3 charCodes

For everyone looking for the char codes corresponding to the keys on your keyboard when programming Flash / Flex, here they are!

A : uint = 65
ALTERNATE : uint = 18
B : uint = 66
BACKQUOTE : uint = 192
BACKSLASH : uint = 220
BACKSPACE : uint = 8
C : uint = 67
CAPS_LOCK : uint = 20
CharCodeStrings : Array
COMMA : uint = 188
COMMAND : uint = 15
CONTROL : uint = 17
D : uint = 68
DELETE : uint = 46
DOWN : uint = 40
E : uint = 69
END : uint = 35
ENTER : uint = 13
EQUAL : uint = 187
ESCAPE : uint = 27
F : uint = 70
F1 : uint = 112
F10 : uint = 121
F11 : uint = 122
F12 : uint = 123
F13 : uint = 124
F14 : uint = 125
F15 : uint = 126
F2 : uint = 113
F3 : uint = 114
F4 : uint = 115
F5 : uint = 116
F6 : uint = 117
F7 : uint = 118
F8 : uint = 119
F9 : uint = 120
G : uint = 71
H : uint = 72
HOME : uint = 36
I : uint = 73
INSERT : uint = 45
J : uint = 74
K : uint = 75

KEYNAME_BEGIN : String = “Begin”
KEYNAME_BREAK : String = “Break”
KEYNAME_CLEARDISPLAY : String = “ClrDsp”
KEYNAME_CLEARLINE : String = “ClrLn”
KEYNAME_DELETE : String = “Delete”
KEYNAME_DELETECHAR : String = “DelChr”
KEYNAME_DELETELINE : String = “DelLn”
KEYNAME_DOWNARROW : String = “Down”
KEYNAME_END : String = “End”
KEYNAME_EXECUTE : String = “Exec”
KEYNAME_F1 : String = “F1″
KEYNAME_F10 : String = “F10″
KEYNAME_F11 : String = “F11″
KEYNAME_F12 : String = “F12″
KEYNAME_F13 : String = “F13″
KEYNAME_F14 : String = “F14″
KEYNAME_F15 : String = “F15″
KEYNAME_F16 : String = “F16″
KEYNAME_F17 : String = “F17″
KEYNAME_F18 : String = “F18″
KEYNAME_F19 : String = “F19″
KEYNAME_F2 : String = “F2″
KEYNAME_F20 : String = “F20″
KEYNAME_F21 : String = “F21″
KEYNAME_F22 : String = “F22″
KEYNAME_F23 : String = “F23″
KEYNAME_F24 : String = “F24″
KEYNAME_F25 : String = “F25″
KEYNAME_F26 : String = “F26″
KEYNAME_F27 : String = “F27″
KEYNAME_F28 : String = “F28″
KEYNAME_F29 : String = “F29″
KEYNAME_F3 : String = “F3″
KEYNAME_F30 : String = “F30″
KEYNAME_F31 : String = “F31″
KEYNAME_F32 : String = “F32″
KEYNAME_F33 : String = “F33″
KEYNAME_F34 : String = “F34″
KEYNAME_F35 : String = “F35″
KEYNAME_F4 : String = “F4″
KEYNAME_F5 : String = “F5″
KEYNAME_F6 : String = “F6″
KEYNAME_F7 : String = “F7″
KEYNAME_F8 : String = “F8″
KEYNAME_F9 : String = “F9″
KEYNAME_FIND : String = “Find”
KEYNAME_HELP : String = “Help”
KEYNAME_HOME : String = “Home”
KEYNAME_INSERT : String = “Insert”
KEYNAME_INSERTCHAR : String = “InsChr”
KEYNAME_INSERTLINE : String = “InsLn”
KEYNAME_LEFTARROW : String = “Left”
KEYNAME_MENU : String = “Menu”
KEYNAME_MODESWITCH : String = “ModeSw”
KEYNAME_NEXT : String = “Next”
KEYNAME_PAGEDOWN : String = “PgDn”
KEYNAME_PAGEUP : String = “PgUp”
KEYNAME_PAUSE : String = “Pause”
KEYNAME_PREV : String = “Prev”
KEYNAME_PRINT : String = “Print”
KEYNAME_PRINTSCREEN : String = “PrntScrn”
KEYNAME_REDO : String = “Redo”
KEYNAME_RESET : String = “Reset”
KEYNAME_RIGHTARROW : String = “Right”
KEYNAME_SCROLLLOCK : String = “ScrlLck”
KEYNAME_SELECT : String = “Select”
KEYNAME_STOP : String = “Stop”
KEYNAME_SYSREQ : String = “SysReq”
KEYNAME_SYSTEM : String = “Sys”
KEYNAME_UNDO : String = “Undo”
KEYNAME_UPARROW : String = “Up”
KEYNAME_USER : String = “User”

L : uint = 76

LEFT : uint = 37
LEFTBRACKET : uint = 219
M : uint = 77
MINUS : uint = 189
N : uint = 78
NUMBER_0 : uint = 48
NUMBER_1 : uint = 49
NUMBER_2 : uint = 50
NUMBER_3 : uint = 51
NUMBER_4 : uint = 52
NUMBER_5 : uint = 53
NUMBER_6 : uint = 54
NUMBER_7 : uint = 55
NUMBER_8 : uint = 56
NUMBER_9 : uint = 57
NUMPAD : uint = 21
NUMPAD_0 : uint = 96
NUMPAD_1 : uint = 97
NUMPAD_2 : uint = 98
NUMPAD_3 : uint = 99
NUMPAD_4 : uint = 100
NUMPAD_5 : uint = 101
NUMPAD_6 : uint = 102
NUMPAD_7 : uint = 103
NUMPAD_8 : uint = 104
UMPAD_9 : uint = 105
NUMPAD_ADD : uint = 107
NUMPAD_DECIMAL : uint = 110
NUMPAD_DIVIDE : uint = 111
NUMPAD_ENTER : uint = 108
NUMPAD_MULTIPLY : uint = 106
NUMPAD_SUBTRACT : uint = 109
O : uint = 79
P : uint = 80
PAGE_DOWN : uint = 34
PAGE_UP : uint = 33
PERIOD : uint = 190
Q : uint = 81
QUOTE : uint = 222
R : uint = 82
RIGHT : uint = 39
RIGHTBRACKET : uint = 221
S : uint = 83
SEMICOLON : uint = 186
SHIFT : uint = 16
SLASH : uint = 191
SPACE : uint = 32
T : uint = 84
TAB : uint = 9
U : uint = 85
UP : uint = 38
V : uint = 86
W : uint = 87
X : uint = 88
Y : uint = 89
Z : uint = 90

For the swedes out there I also included the Swedish chars:

å : uint = 229
ä : uint = 228
ö : uint = 246

Å : uint = 197
Ä : uint = 196
Ö : uint = 214

If you have any more, Share!

Jameson on 09/01/08

Hey.. you are missing some chars.. what about all the non capital letters? Great resource anywho!
Cheers

Stag night ideas on 01/27/09

Hi Fredrik,
Thanks for posting these – it saved me quite a lot of time & hassle :-)

Cheers,
James

Fredrik on 01/27/09

No worries, glad I could help. There are however some more in depth issues with the charCodes that I came across when working on different keyboard layouts. Lower case chars is also defined by their own charCodes. So A != a. Take care!

Huge thanks for this list, man. Adobe sucks complete ass for not having a simple table like that in their help documentation (and if they do, I couldn’t find it within 5 minutes so it is located somewhere that is NOT helpful).

andre on 05/28/09

thanks!! Flash doesn’t trace the Escape key and it sucks to create a textfield to print values under a browser.

thanks!

Jaime on 09/02/09

Ow yeah, Flash doesn’t trace the Escape key(and other keys that are shortcuts) because a conflict with player sandBox and the Flash interface; it understand that keys pressed is for the flash interface shortcuts. sucks

Paul on 09/24/09

Very handy utility! Thanks for sharing these char codes.

sam on 12/14/09

You can also get the charcode with the charCodeAt function :

e.g.

“A”.charCodeAt(0)

Fredrik on 01/10/10

Ahh.. thats a nice way to do it too :)

在线代理 on 07/17/10

赞一个 文章写的挺好 支持一下

Rasmus on 11/15/10

Nice flash app there – helped me quite alot

tension on 02/11/11

NEW LINE: uint = 10
CARRIAGE RETURN: uint = 13

Keegan on 04/22/11

These are the charCodes for lowercase letters in the alphabet, a-z:

a = 97
b = 98
c = 99
d = 100
e = 101
f = 102
g = 103
h = 104
i = 105
j = 106
k = 107
l = 108
m = 109
n = 110
o = 111
p = 112
q = 113
r = 114
s = 115
t = 116
u = 117
v = 118
w = 119
x = 120
y = 121
z = 122

Nick on 04/11/12

There seems to be some confusion here. The list presented above is a list of keycodes, not charcodes. There are no lowercase characters in the list because the keycode is associated with the key on the keyboard, so it is the same for uppercase and lowercase. When capturing a keyboard event such as KeyboardEvent.KEY_DOWN, you can compare event.keyCode to the values above like so:

// Keyboard.A == 65
if (event.keyCode == Keyboard.A) {
// This will be true when the ‘A’ key is pressed, regardless of whether shift is held down or not
}

Charcodes are the values for each individual character. If you want to determine whether a specific character is typed, you would compare its charCode, like so:

// ‘a’.charCodeAt() == 97
// ‘A’.charCodeAt() == 65
if (event.charCode == ‘a’.charCodeAt()) {
// This will be true only when a lowercase ‘a’ is typed (shift key is not held down)
}

Leave a comment

Name (required)

Mail (required)

Website

Text