Posted By

alistairholt on 10/23/10


Tagged

carbon


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite



Carbon's Virtual Key Codes


 / Published in: Objective C
 

  1. /*
  2.  * Summary:
  3.  * Virtual keycodes
  4.  *
  5.  * Discussion:
  6.  * These constants are the virtual keycodes defined originally in
  7.  * Inside Mac Volume V, pg. V-191. They identify physical keys on a
  8.  * keyboard. Those constants with "ANSI" in the name are labeled
  9.  * according to the key position on an ANSI-standard US keyboard.
  10.  * For example, kVK_ANSI_A indicates the virtual keycode for the key
  11.  * with the letter 'A' in the US keyboard layout. Other keyboard
  12.  * layouts may have the 'A' key label on a different physical key;
  13.  * in this case, pressing 'A' will generate a different virtual
  14.  * keycode.
  15.  */
  16. enum {
  17. kVK_ANSI_A = 0x00,
  18. kVK_ANSI_S = 0x01,
  19. kVK_ANSI_D = 0x02,
  20. kVK_ANSI_F = 0x03,
  21. kVK_ANSI_H = 0x04,
  22. kVK_ANSI_G = 0x05,
  23. kVK_ANSI_Z = 0x06,
  24. kVK_ANSI_X = 0x07,
  25. kVK_ANSI_C = 0x08,
  26. kVK_ANSI_V = 0x09,
  27. kVK_ANSI_B = 0x0B,
  28. kVK_ANSI_Q = 0x0C,
  29. kVK_ANSI_W = 0x0D,
  30. kVK_ANSI_E = 0x0E,
  31. kVK_ANSI_R = 0x0F,
  32. kVK_ANSI_Y = 0x10,
  33. kVK_ANSI_T = 0x11,
  34. kVK_ANSI_1 = 0x12,
  35. kVK_ANSI_2 = 0x13,
  36. kVK_ANSI_3 = 0x14,
  37. kVK_ANSI_4 = 0x15,
  38. kVK_ANSI_6 = 0x16,
  39. kVK_ANSI_5 = 0x17,
  40. kVK_ANSI_Equal = 0x18,
  41. kVK_ANSI_9 = 0x19,
  42. kVK_ANSI_7 = 0x1A,
  43. kVK_ANSI_Minus = 0x1B,
  44. kVK_ANSI_8 = 0x1C,
  45. kVK_ANSI_0 = 0x1D,
  46. kVK_ANSI_RightBracket = 0x1E,
  47. kVK_ANSI_O = 0x1F,
  48. kVK_ANSI_U = 0x20,
  49. kVK_ANSI_LeftBracket = 0x21,
  50. kVK_ANSI_I = 0x22,
  51. kVK_ANSI_P = 0x23,
  52. kVK_ANSI_L = 0x25,
  53. kVK_ANSI_J = 0x26,
  54. kVK_ANSI_Quote = 0x27,
  55. kVK_ANSI_K = 0x28,
  56. kVK_ANSI_Semicolon = 0x29,
  57. kVK_ANSI_Backslash = 0x2A,
  58. kVK_ANSI_Comma = 0x2B,
  59. kVK_ANSI_Slash = 0x2C,
  60. kVK_ANSI_N = 0x2D,
  61. kVK_ANSI_M = 0x2E,
  62. kVK_ANSI_Period = 0x2F,
  63. kVK_ANSI_Grave = 0x32,
  64. kVK_ANSI_KeypadDecimal = 0x41,
  65. kVK_ANSI_KeypadMultiply = 0x43,
  66. kVK_ANSI_KeypadPlus = 0x45,
  67. kVK_ANSI_KeypadClear = 0x47,
  68. kVK_ANSI_KeypadDivide = 0x4B,
  69. kVK_ANSI_KeypadEnter = 0x4C,
  70. kVK_ANSI_KeypadMinus = 0x4E,
  71. kVK_ANSI_KeypadEquals = 0x51,
  72. kVK_ANSI_Keypad0 = 0x52,
  73. kVK_ANSI_Keypad1 = 0x53,
  74. kVK_ANSI_Keypad2 = 0x54,
  75. kVK_ANSI_Keypad3 = 0x55,
  76. kVK_ANSI_Keypad4 = 0x56,
  77. kVK_ANSI_Keypad5 = 0x57,
  78. kVK_ANSI_Keypad6 = 0x58,
  79. kVK_ANSI_Keypad7 = 0x59,
  80. kVK_ANSI_Keypad8 = 0x5B,
  81. kVK_ANSI_Keypad9 = 0x5C
  82. };
  83.  
  84. /* keycodes for keys that are independent of keyboard layout*/
  85. enum {
  86. kVK_Return = 0x24,
  87. kVK_Tab = 0x30,
  88. kVK_Space = 0x31,
  89. kVK_Delete = 0x33,
  90. kVK_Escape = 0x35,
  91. kVK_Command = 0x37,
  92. kVK_Shift = 0x38,
  93. kVK_CapsLock = 0x39,
  94. kVK_Option = 0x3A,
  95. kVK_Control = 0x3B,
  96. kVK_RightShift = 0x3C,
  97. kVK_RightOption = 0x3D,
  98. kVK_RightControl = 0x3E,
  99. kVK_Function = 0x3F,
  100. kVK_F17 = 0x40,
  101. kVK_VolumeUp = 0x48,
  102. kVK_VolumeDown = 0x49,
  103. kVK_Mute = 0x4A,
  104. kVK_F18 = 0x4F,
  105. kVK_F19 = 0x50,
  106. kVK_F20 = 0x5A,
  107. kVK_F5 = 0x60,
  108. kVK_F6 = 0x61,
  109. kVK_F7 = 0x62,
  110. kVK_F3 = 0x63,
  111. kVK_F8 = 0x64,
  112. kVK_F9 = 0x65,
  113. kVK_F11 = 0x67,
  114. kVK_F13 = 0x69,
  115. kVK_F16 = 0x6A,
  116. kVK_F14 = 0x6B,
  117. kVK_F10 = 0x6D,
  118. kVK_F12 = 0x6F,
  119. kVK_F15 = 0x71,
  120. kVK_Help = 0x72,
  121. kVK_Home = 0x73,
  122. kVK_PageUp = 0x74,
  123. kVK_ForwardDelete = 0x75,
  124. kVK_F4 = 0x76,
  125. kVK_End = 0x77,
  126. kVK_F2 = 0x78,
  127. kVK_PageDown = 0x79,
  128. kVK_F1 = 0x7A,
  129. kVK_LeftArrow = 0x7B,
  130. kVK_RightArrow = 0x7C,
  131. kVK_DownArrow = 0x7D,
  132. kVK_UpArrow = 0x7E
  133. };
  134.  
  135. /* ISO keyboards only*/
  136. enum {
  137. kVK_ISO_Section = 0x0A
  138. };
  139.  
  140. /* JIS keyboards only*/
  141. enum {
  142. kVK_JIS_Yen = 0x5D,
  143. kVK_JIS_Underscore = 0x5E,
  144. kVK_JIS_KeypadComma = 0x5F,
  145. kVK_JIS_Eisu = 0x66,
  146. kVK_JIS_Kana = 0x68
  147. };

Report this snippet  

You need to login to post a comment.