View comments | RSS feed

Keyboard keys and key code values overview

The following tables list all the keys on a standard keyboard and the corresponding ASCII key code values that are used to identify the keys in ActionScript:

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 ASCII key code values that are used to identify the keys in ActionScript:

Letter or number key Key code

A

65

B

66

C

67

D

68

E

69

F

70

G

71

H

72

I

73

J

74

K

75

L

76

M

77

N

78

O

79

P

80

Q

81

R

82

S

83

T

84

U

85

V

86

W

87

X

88

Y

89

Z

90

0

48

1

49

2

50

3

51

4

52

5

53

6

54

7

55

8

56

9

57


Comments


No screen name said on Sep 8, 2004 at 4:54 AM :
Put all four tables on one page, or just make it one table with various headers and anchor tags for each header.

Also, speed up people's download time by getting an html editor that doesn't add paragraph tags to all the table entries.
No screen name said on Sep 12, 2004 at 1:36 PM :
It would help if they were correct:
Using the shift key and tracing Key.getCode() will give a different answer for upper and lower case
No screen name said on Jul 12, 2005 at 8:58 AM :
They key codes are ISO Latin 1 Characters.

You can find tables of them all over the net. Example:

http://www.bbsinc.com/symbol.html

Perhaps someone who can update the LiveDocs would transfer one of the tables into this LiveDocs page.
.p. said on Aug 4, 2005 at 8:33 AM :
Neither of the previous two comments are correct. There is a big difference between Key.getCode() and Key.getAscii().

The chart above lists only the values returned by Key.getCode(), which is unaffected by modifier keys such as SHIFT, and differs from Key.getAscii() by providing codes for non alpha-numeric keys like the arrows (which don't have a standard ASCII value). The chart title should be made clearer, but the values are correct for Key.getCode().

Key.getAscii() does return different values whether the SHIFT key is up or down. ASCII value charts are all over the web. The above chart only matches ASCII values for alpha-numeric keys when the SHIFT key is down.

Test the following code on the root of a new flash movie and hit some keys to clarify the differences:

Key.addListener({onKeyUp:function(){trace("Key.getCode() "+Key.getCode() +"\nKey.getAscii() "+Key.getAscii());}});
jepo said on Aug 4, 2005 at 11:16 AM :
That's correct (last comment). The next revision of the documentation will have both key code values and ascii values included in this table (which will also appear on one easily printable page).
No screen name said on Aug 9, 2005 at 9:05 AM :
This is all fine and good, but what do I do with these keycodes?

I'm trying to use one of these codes to allow my users to press a certain key (say F3) to continue - but I can't figure out how b/c I don't know how to use these keycodes in an on(keyPress) function.

-- Some examples might help.
No screen name said on Sep 22, 2005 at 10:09 AM :
please describe on(keyPress "keycode"), tryed everiting but not working....
pulsar150 said on Sep 29, 2005 at 11:15 PM :
//just give stop() at a desired frame and just wait for the user to press F3 to continue..... after F3 is pressed the code below works and give the frame from where u intend to start at gotoAndPlay inside if condition as shown


var myListener:Object=new Object();
myListener.onKeyUp = function () {
if(Key.getCode()==114){
//your code goes here
//if u want to continue just give gotoAndPlay(your prefered position [frame position])
}
}
Key.addListener(myListener);
No screen name said on Sep 30, 2005 at 3:25 AM :
OK, I have several MovieClips and on(press) action on each of them, like..
(mc1) - on(press or keyPress "1") {
//code to execute
}
(mc2) - on(press or keyPress "2") {
//code to execute
}
... and so on...
this work fine, but it work on keys "1", "2",... even if you pressing those keys on numeric keybord, what if I wont to use keys on numeric keybord for something else, like for another player supouse. I want those MovieClips to react on mouse press and/or on key press 1,2,3,... but only on main keybord. What should i do? How the syntax of on(press or keyPress "keycode") would look like? I try almoste everithing.... :( . Is it posible at all to write on() event whith keyPress <keycode> ?
fezboa said on Nov 21, 2005 at 1:46 PM :
The keycodes for linux (X.org Server) are diffrent. See /usr/lib/X11/xkb/keycodes.
fezboa
mac90210 said on Aug 8, 2007 at 5:46 PM :
What about keys like shift and ctrl?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001113.html