iOS keycodes in Javascript

Here are the iOS keycodes for the keyDown and keyPress events in JavaScript as generated by an iPad running iOS 4.3.3:

Key keyDown keyPress notes
<return> 13 13
backspace 8
<space> 32 32
a 65 97
b 66 98
c 67 99
d 68 100
e 69 101
f 70 102
g 71 103
h 72 104
i 73 105
j 74 106
k 75 107
l 76 108
m 77 109
n 78 110
o 79 111
p 80 112
q 81 113
r 82 114
s 83 115
t 84 116
u 85 117
v 86 118
w 87 119
x 88 120
y 89 121
z 90 122
A 65 65
B 66 66
C 67 67
D 68 68
E 69 69
F 70 70
G 71 71
H 72 72
I 73 73
J 74 74
K 75 75
L 76 76
M 77 77
N 78 78
O 79 79
P 80 80
Q 81 81
R 82 82
S 83 83
T 84 84
U 85 85
V 86 86
W 87 87
X 88 88
Y 89 89
Z 90 90
! 49 33
222 39 single quote
. 190 46
222 34 double quote
1 49 49
2 50 50
3 51 51
4 52 52
5 53 53
6 54 54
7 55 55
8 56 56
9 57 57
0 48 48
189 45 hyphen
0 8212 em dash
? 0 8226 Bullet
/ 191 47
: 186 58
; 186 59
( 57 40
) 48 41
$ 52 36
& 55 38
§ 0 167
@ 50 64
. 190 46
0 8230
, 188 44
? 191 63
¿ 0 191
¡ 0 161
[ 219 91
] 221 93
{ 219 123
} 221 125
# 51 35
% 53 37
0 8240
^ 54 94
* 56 42
+ 187 43
= 187 61
_ 189 95
\ 220 92
| 220 124
~ 192 126
< 188 60
> 190 62
0 8394
£ 0 163
¥ 0 165
? 0 12289 enumeration comma
? 0 12290 Asian full stop
? 0 12540 chouonpu (???)
? 0 9787 Any smiley, actually

5 Responses to “iOS keycodes in Javascript”

  1. David Switch writes:

    Thanks will file this list away for reference 🙂 Wonder how it differs from normal keycodes.

  2. Bruce writes:

    Any idea about the “special” keys like next, undo, redo, cut, paste, etc?
    Some like undo, redo, paste don’t seem to generate any keydown/keypress events (detectable by JavaScript) at all even tho they change the contents of the form input field!

  3. eric writes:

    “Undo”, “Next”, etc. aren’t keyboard keys, so they’re not represented. If you’re concerned about the input fields changing, then add an onchange handler. But in general, these are keys “beyond” the realm of the web page.

  4. Bruce writes:

    Yeah, unfortunately the change event isnt fired until the user leaves the field…I need to react immediately to implement “type-ahead” like features…UNDO/REDO/PASTE break the ability to do that since there is no event to react to until some arbitrarily later event like blur or the user getting around to typing the next normal key. 🙁

  5. Christian writes:

    Hi Bruce, Eric, do you have a solution to your paste problem? I have got the same problem, since I have to restrict a textarea by the number of lines dynamically via event handling in Javaascript. This works on all browsers, since I am listening on keyup event. But unfortunately this does not work on the iPhone/iPad.
    The only “solution” that came to my mind was to implement a dirty “setTimeout” listener that checks for changes of the contents every few milliseconds. But this is really dirty …

Leave a Reply