3
unfortunately, mac key codes are keyboard specific:
4
that is, there is no universal VK_A, but every keyboard has its code for VK_A
5
Key codes depend on physical key position on the keyboard: considering a
6
QWERTY keyboard and an AZERTY one, keycode(Q) of first one = keycode(A) of
7
the second one, and so on.
8
For "printable" keys we can rely on kEventParamKeyMacCharCodes and
9
kEventParamKeyUnicodes event parameters to obtain an ascii/unicode value
10
that we can translate to the appropriate VK_ code
11
For non printable keys (Function, ins, arrow and so on...) we use the raw
12
keycodes, since it looks like they are constant across all keyboards
14
So, here are constants for non-printable keys (MK means "Mac Key").
15
These constants were extracted using KeyCodes program by Peter Maurer
16
(http://www.petermaurer.de/nasi.php?section=keycodes)
18
Some keys were taken from the ancient "Macintosh Toolbox Essentials", page 87
19
http://developer.apple.com/documentation/mac/pdf/MacintoshToolboxEssentials.pdf
38
MK_F13 = $69; MK_PRNSCR = MK_F13; //Print screen = F13
39
MK_F14 = $6B; MK_SCRLOCK = MK_F14; //Scroll Lock = F14
40
MK_F15 = $71; MK_PAUSE = MK_F15; //Pause = F15
43
MK_INS = $72; MK_HELP = MK_INS; //old macs call this key "help"
64
MK_PADEQUALS = $51; //only present in old mac keyboards?
70
MK_PADENTER = $4C; //enter on numeric keypad
75
//Modifiers codes - you'll never get these directly
79
MK_ALT = $3A; MK_OPTION = MK_ALT;
80
MK_COMMAND = $37; MK_APPLE = MK_COMMAND;
82
MK_TILDE = 50; // `/~ key
83
MK_MINUS = 27; // -/_ key
84
MK_EQUAL = 24; // =/+ key
85
MK_BACKSLASH = 42; // \ | key
86
MK_LEFTBRACKET = 33; // [ { key
87
MK_RIGHTBRACKET = 30; // ] } key
88
MK_SEMICOLON = 41; // ; : key
89
MK_QUOTE = 39; // ' " key
90
MK_COMMA = 43; // , < key
91
MK_PERIOD = 47; // . > key
92
MK_SLASH = 44; // / ? key