Skip to content

Instantly share code, notes, and snippets.

@samthecodingman
Created November 14, 2018 20:41
Show Gist options
  • Save samthecodingman/2cc42b531659f8f087359b9429b96890 to your computer and use it in GitHub Desktop.
Save samthecodingman/2cc42b531659f8f087359b9429b96890 to your computer and use it in GitHub Desktop.
An AutoHotkey Library that defines a variable containing maps between a key's numeric ID, AHK hotkey name and Windows VK_* name.
; [LIBRARY] AHK/Windows Key List (Keys.ahk)
; Description: Initializes a variable called KEYS that contains maps between a key's numeric ID, AHK hotkey name, Windows VK_* name and human-friendly description.
; Author: Samuel Jones (@samthecodingman)
; Last-Modified: 06 NOV 2018
; License: MIT (https://opensource.org/licenses/MIT)
; URL: https://gist.github.com/samthecodingman/2cc42b531659f8f087359b9429b96890
; Requires AHK v1.0.90+. Untested with AHK v2+
; Defines: KEYS, Keys_Initialize
KEYS := Keys_Initialize()
Keys_Initialize() {
; Descriptions for special key types
_RES := "Reserved", _UD := "Undefined", _UA := "Unassigned", _OEM := "OEM specific"
; Raw key list before mapping
_RAW := {
(Join
1:{id:0x01,ahk:"LButton",win:"VK_LBUTTON",desc:"Left mouse button"},
2:{id:0x02,ahk:"RButton",win:"VK_RBUTTON",desc:"Right mouse button"},
3:{id:0x03,ahk:"CtrlBreak",win:"VK_CANCEL",desc:"Control-break processing"},
4:{id:0x04,ahk:"MButton",win:"VK_MBUTTON",desc:"Middle mouse button"},
5:{id:0x05,ahk:"XButton1",win:"VK_XBUTTON1",desc:"X1 mouse button"},
6:{id:0x06,ahk:"XButton2",win:"VK_XBUTTON2",desc:"X2 mouse button"},
7:{id:0x07,ahk:"",win:"",desc:_UD},
8:{id:0x08,ahk:"Backspace",win:"VK_BACK",desc:"BACKSPACE key"},
9:{id:0x09,ahk:"Tab",win:"VK_TAB",desc:"TAB key"},
10:{id:0x0A,ahk:"",win:"",desc:_RES},
11:{id:0x0B,ahk:"",win:"",desc:_RES},
12:{id:0x0C,ahk:"NumpadClear",win:"VK_CLEAR",desc:"CLEAR key"},
13:{id:0x0D,ahk:"Enter",win:"VK_RETURN",desc:"ENTER key"},
14:{id:0x0E,ahk:"",win:"",desc:_UD},
15:{id:0x0F,ahk:"",win:"",desc:_UD},
16:{id:0x10,ahk:"Shift",win:"VK_SHIFT",desc:"SHIFT key"},
17:{id:0x11,ahk:"Control",win:"VK_CONTROL",desc:"CTRL key"},
18:{id:0x12,ahk:"Alt",win:"VK_MENU",desc:"ALT key"},
19:{id:0x13,ahk:"Pause",win:"VK_PAUSE",desc:"PAUSE key"},
20:{id:0x14,ahk:"CapsLock",win:"VK_CAPITAL",desc:"CAPS LOCK key"},
21:{id:0x15,ahk:"",win:["VK_KANA","VK_HANGUL"],desc:"IME Kana / Hangul mode"},
22:{id:0x16,ahk:"",win:"",desc:_UD},
23:{id:0x17,ahk:"",win:"VK_JUNJA",desc:"IME Junja mode"},
24:{id:0x18,ahk:"",win:"VK_FINAL",desc:"IME final mode"},
25:{id:0x19,ahk:"",win:["VK_HANJA", "VK_KANJI"],desc:"IME Hanja / Kanji mode"},
26:{id:0x1A,ahk:"",win:"",desc:_UD},
27:{id:0x1B,ahk:"Escape",win:"VK_ESCAPE",desc:"ESC key"},
28:{id:0x1C,ahk:"",win:"VK_CONVERT",desc:"IME convert"},
29:{id:0x1D,ahk:"",win:"VK_NONCONVERT",desc:"IME nonconvert"},
30:{id:0x1E,ahk:"",win:"VK_ACCEPT",desc:"IME accept"},
31:{id:0x1F,ahk:"",win:"VK_MODECHANGE",desc:"IME mode change request"},
32:{id:0x20,ahk:"Space",win:"VK_SPACE",desc:"SPACEBAR"},
33:{id:0x21,ahk:"NumpadPgUp",win:"VK_PRIOR",desc:"PAGE UP key"},
34:{id:0x22,ahk:"NumpadPgDn",win:"VK_NEXT",desc:"PAGE DOWN key"},
35:{id:0x23,ahk:"NumpadEnd",win:"VK_END",desc:"END key"},
36:{id:0x24,ahk:"NumpadHome",win:"VK_HOME",desc:"HOME key"},
37:{id:0x25,ahk:"NumpadLeft",win:"VK_LEFT",desc:"LEFT ARROW key"},
38:{id:0x26,ahk:"NumpadUp",win:"VK_UP",desc:"UP ARROW key"},
39:{id:0x27,ahk:"NumpadRight",win:"VK_RIGHT",desc:"RIGHT ARROW key"},
40:{id:0x28,ahk:"NumpadDown",win:"VK_DOWN",desc:"DOWN ARROW key"},
41:{id:0x29,ahk:"",win:"VK_SELECT",desc:"SELECT key"},
42:{id:0x2A,ahk:"",win:"VK_PRINT",desc:"PRINT key"},
43:{id:0x2B,ahk:"",win:"VK_EXECUTE",desc:"EXECUTE key"},
44:{id:0x2C,ahk:"PrintScreen",win:"VK_SNAPSHOT",desc:"PRINT SCREEN key"},
45:{id:0x2D,ahk:"NumpadIns",win:"VK_INSERT",desc:"INS key"},
46:{id:0x2E,ahk:"NumpadDel",win:"VK_DELETE",desc:"DEL key"},
47:{id:0x2F,ahk:"Help",win:"VK_HELP",desc:"HELP key"},
48:{id:0x30,ahk:"0",win:"",desc:"0 key"},
49:{id:0x31,ahk:"1",win:"",desc:"1 key"},
50:{id:0x32,ahk:"2",win:"",desc:"2 key"},
51:{id:0x33,ahk:"3",win:"",desc:"3 key"},
52:{id:0x34,ahk:"4",win:"",desc:"4 key"},
53:{id:0x35,ahk:"5",win:"",desc:"5 key"},
54:{id:0x36,ahk:"6",win:"",desc:"6 key"},
55:{id:0x37,ahk:"7",win:"",desc:"7 key"},
56:{id:0x38,ahk:"8",win:"",desc:"8 key"},
57:{id:0x39,ahk:"9",win:"",desc:"9 key"},
58:{id:0x3A,ahk:"",win:"",desc:_UD},
59:{id:0x3B,ahk:"",win:"",desc:_UD},
60:{id:0x3C,ahk:"",win:"",desc:_UD},
61:{id:0x3D,ahk:"",win:"",desc:_UD},
62:{id:0x3E,ahk:"",win:"",desc:_UD},
63:{id:0x3F,ahk:"",win:"",desc:_UD},
64:{id:0x40,ahk:"",win:"",desc:_UD},
65:{id:0x41,ahk:"A",win:"",desc:"A key"},
66:{id:0x42,ahk:"B",win:"",desc:"B key"},
67:{id:0x43,ahk:"C",win:"",desc:"C key"},
68:{id:0x44,ahk:"D",win:"",desc:"D key"},
69:{id:0x45,ahk:"E",win:"",desc:"E key"},
70:{id:0x46,ahk:"F",win:"",desc:"F key"},
71:{id:0x47,ahk:"G",win:"",desc:"G key"},
72:{id:0x48,ahk:"H",win:"",desc:"H key"},
73:{id:0x49,ahk:"I",win:"",desc:"I key"},
74:{id:0x4A,ahk:"J",win:"",desc:"J key"},
75:{id:0x4B,ahk:"K",win:"",desc:"K key"},
76:{id:0x4C,ahk:"L",win:"",desc:"L key"},
77:{id:0x4D,ahk:"M",win:"",desc:"M key"},
78:{id:0x4E,ahk:"N",win:"",desc:"N key"},
79:{id:0x4F,ahk:"O",win:"",desc:"O key"},
80:{id:0x50,ahk:"P",win:"",desc:"P key"},
81:{id:0x51,ahk:"Q",win:"",desc:"Q key"},
82:{id:0x52,ahk:"R",win:"",desc:"R key"},
83:{id:0x53,ahk:"S",win:"",desc:"S key"},
84:{id:0x54,ahk:"T",win:"",desc:"T key"},
85:{id:0x55,ahk:"U",win:"",desc:"U key"},
86:{id:0x56,ahk:"V",win:"",desc:"V key"},
87:{id:0x57,ahk:"W",win:"",desc:"W key"},
88:{id:0x58,ahk:"X",win:"",desc:"X key"},
89:{id:0x59,ahk:"Y",win:"",desc:"Y key"},
90:{id:0x5A,ahk:"Z",win:"",desc:"Z key"},
91:{id:0x5B,ahk:"LWin",win:"VK_LWIN",desc:"Left Windows key (Natural keyboard) "},
92:{id:0x5C,ahk:"RWin",win:"VK_RWIN",desc:"Right Windows key (Natural keyboard)"},
93:{id:0x5D,ahk:"AppsKey",win:"VK_APPS",desc:"Applications key (Natural keyboard)"},
94:{id:0x5E,ahk:"",win:"",desc:_RES},
95:{id:0x5F,ahk:"Sleep",win:"VK_SLEEP",desc:"Computer Sleep key"},
96:{id:0x60,ahk:"Numpad0",win:"VK_NUMPAD0",desc:"Numeric keypad 0 key"},
97:{id:0x61,ahk:"Numpad1",win:"VK_NUMPAD1",desc:"Numeric keypad 1 key"},
98:{id:0x62,ahk:"Numpad2",win:"VK_NUMPAD2",desc:"Numeric keypad 2 key"},
99:{id:0x63,ahk:"Numpad3",win:"VK_NUMPAD3",desc:"Numeric keypad 3 key"},
100:{id:0x64,ahk:"Numpad4",win:"VK_NUMPAD4",desc:"Numeric keypad 4 key"},
101:{id:0x65,ahk:"Numpad5",win:"VK_NUMPAD5",desc:"Numeric keypad 5 key"},
102:{id:0x66,ahk:"Numpad6",win:"VK_NUMPAD6",desc:"Numeric keypad 6 key"},
103:{id:0x67,ahk:"Numpad7",win:"VK_NUMPAD7",desc:"Numeric keypad 7 key"},
104:{id:0x68,ahk:"Numpad8",win:"VK_NUMPAD8",desc:"Numeric keypad 8 key"},
105:{id:0x69,ahk:"Numpad9",win:"VK_NUMPAD9",desc:"Numeric keypad 9 key"},
106:{id:0x6A,ahk:"NumpadMult",win:"VK_MULTIPLY",desc:"Multiply key"},
107:{id:0x6B,ahk:"NumpadAdd",win:"VK_ADD",desc:"Add key"},
108:{id:0x6C,ahk:"",win:"VK_SEPARATOR",desc:"Separator key"},
109:{id:0x6D,ahk:"NumpadSub",win:"VK_SUBTRACT",desc:"Subtract key"},
110:{id:0x6E,ahk:"NumpadDot",win:"VK_DECIMAL",desc:"Decimal key"},
111:{id:0x6F,ahk:"NumpadDiv",win:"VK_DIVIDE",desc:"Divide key"},
112:{id:0x70,ahk:"F1",win:"VK_F1",desc:"F1 key"},
113:{id:0x71,ahk:"F2",win:"VK_F2",desc:"F2 key"},
114:{id:0x72,ahk:"F3",win:"VK_F3",desc:"F3 key"},
115:{id:0x73,ahk:"F4",win:"VK_F4",desc:"F4 key"},
116:{id:0x74,ahk:"F5",win:"VK_F5",desc:"F5 key"},
117:{id:0x75,ahk:"F6",win:"VK_F6",desc:"F6 key"},
118:{id:0x76,ahk:"F7",win:"VK_F7",desc:"F7 key"},
119:{id:0x77,ahk:"F8",win:"VK_F8",desc:"F8 key"},
120:{id:0x78,ahk:"F9",win:"VK_F9",desc:"F9 key"},
121:{id:0x79,ahk:"F10",win:"VK_F10",desc:"F10 key"},
122:{id:0x7A,ahk:"F11",win:"VK_F11",desc:"F11 key"},
123:{id:0x7B,ahk:"F12",win:"VK_F12",desc:"F12 key"},
124:{id:0x7C,ahk:"F13",win:"VK_F13",desc:"F13 key"},
125:{id:0x7D,ahk:"F14",win:"VK_F14",desc:"F14 key"},
126:{id:0x7E,ahk:"F15",win:"VK_F15",desc:"F15 key"},
127:{id:0x7F,ahk:"F16",win:"VK_F16",desc:"F16 key"},
128:{id:0x80,ahk:"F17",win:"VK_F17",desc:"F17 key"},
129:{id:0x81,ahk:"F18",win:"VK_F18",desc:"F18 key"},
130:{id:0x82,ahk:"F19",win:"VK_F19",desc:"F19 key"},
131:{id:0x83,ahk:"F20",win:"VK_F20",desc:"F20 key"},
132:{id:0x84,ahk:"F21",win:"VK_F21",desc:"F21 key"},
133:{id:0x85,ahk:"F22",win:"VK_F22",desc:"F22 key"},
134:{id:0x86,ahk:"F23",win:"VK_F23",desc:"F23 key"},
135:{id:0x87,ahk:"F24",win:"VK_F24",desc:"F24 key"},
136:{id:0x88,ahk:"",win:"",desc:_UA},
137:{id:0x89,ahk:"",win:"",desc:_UA},
138:{id:0x8A,ahk:"",win:"",desc:_UA},
139:{id:0x8B,ahk:"",win:"",desc:_UA},
140:{id:0x8C,ahk:"",win:"",desc:_UA},
141:{id:0x8D,ahk:"",win:"",desc:_UA},
142:{id:0x8E,ahk:"",win:"",desc:_UA},
143:{id:0x8F,ahk:"",win:"",desc:_UA},
144:{id:0x90,ahk:"Numlock",win:"VK_NUMLOCK",desc:"NUM LOCK key"},
145:{id:0x91,ahk:"ScrollLock",win:"VK_SCROLL",desc:"SCROLL LOCK key"},
146:{id:0x92,ahk:"",win:"",desc:_OEM},
147:{id:0x93,ahk:"",win:"",desc:_OEM},
148:{id:0x94,ahk:"",win:"",desc:_OEM},
149:{id:0x95,ahk:"",win:"",desc:_OEM},
150:{id:0x96,ahk:"",win:"",desc:_OEM},
151:{id:0x97,ahk:"",win:"",desc:_UA},
152:{id:0x98,ahk:"",win:"",desc:_UA},
153:{id:0x99,ahk:"",win:"",desc:_UA},
154:{id:0x9A,ahk:"",win:"",desc:_UA},
155:{id:0x9B,ahk:"",win:"",desc:_UA},
156:{id:0x9C,ahk:"",win:"",desc:_UA},
157:{id:0x9D,ahk:"",win:"",desc:_UA},
158:{id:0x9E,ahk:"",win:"",desc:_UA},
159:{id:0x9F,ahk:"",win:"",desc:_UA},
160:{id:0xA0,ahk:"LShift",win:"VK_LSHIFT",desc:"Left SHIFT key"},
161:{id:0xA1,ahk:"RShift",win:"VK_RSHIFT",desc:"Right SHIFT key"},
162:{id:0xA2,ahk:"LCtrl",win:"VK_LCONTROL",desc:"Left CONTROL key"},
163:{id:0xA3,ahk:"RCtrl",win:"VK_RCONTROL",desc:"Right CONTROL key"},
164:{id:0xA4,ahk:"LAlt",win:"VK_LMENU",desc:"Left MENU key"},
165:{id:0xA5,ahk:"RAlt",win:"VK_RMENU",desc:"Right MENU key"},
166:{id:0xA6,ahk:"Browser_Back",win:"VK_BROWSER_BACK",desc:"Browser Back key"},
167:{id:0xA7,ahk:"Browser_Forward",win:"VK_BROWSER_FORWARD",desc:"Browser Forward key"},
168:{id:0xA8,ahk:"Browser_Refresh",win:"VK_BROWSER_REFRESH",desc:"Browser Refresh key"},
169:{id:0xA9,ahk:"Browser_Stop",win:"VK_BROWSER_STOP",desc:"Browser Stop key"},
170:{id:0xAA,ahk:"Browser_Search",win:"VK_BROWSER_SEARCH",desc:"Browser Search key "},
171:{id:0xAB,ahk:"Browser_Favorites",win:"VK_BROWSER_FAVORITES",desc:"Browser Favorites key"},
172:{id:0xAC,ahk:"Browser_Home",win:"VK_BROWSER_HOME",desc:"Browser Start and Home key"},
173:{id:0xAD,ahk:"Volume_Mute",win:"VK_VOLUME_MUTE",desc:"Volume Mute key"},
174:{id:0xAE,ahk:"Volume_Down",win:"VK_VOLUME_DOWN",desc:"Volume Down key"},
175:{id:0xAF,ahk:"Volume_Up",win:"VK_VOLUME_UP",desc:"Volume Up key"},
176:{id:0xB0,ahk:"Media_Next",win:"VK_MEDIA_NEXT_TRACK",desc:"Next Track key"},
177:{id:0xB1,ahk:"Media_Prev",win:"VK_MEDIA_PREV_TRACK",desc:"Previous Track key"},
178:{id:0xB2,ahk:"Media_Stop",win:"VK_MEDIA_STOP",desc:"Stop Media key"},
179:{id:0xB3,ahk:"Media_Play_Pause",win:"VK_MEDIA_PLAY_PAUSE",desc:"Play/Pause Media key"},
180:{id:0xB4,ahk:"Launch_Mail",win:"VK_LAUNCH_MAIL",desc:"Start Mail key"},
181:{id:0xB5,ahk:"Launch_Media",win:"VK_LAUNCH_MEDIA_SELECT",desc:"Select Media key"},
182:{id:0xB6,ahk:"Launch_App1",win:"VK_LAUNCH_APP1",desc:"Start Application 1 key"},
183:{id:0xB7,ahk:"Launch_App2",win:"VK_LAUNCH_APP2",desc:"Start Application 2 key"},
184:{id:0xB8,ahk:"",win:"-",desc:_RES},
185:{id:0xB9,ahk:"",win:"-",desc:_RES},
186:{id:0xBA,ahk:";",win:"VK_OEM_1",desc:"US ';:' key"},
187:{id:0xBB,ahk:"=",win:"VK_OEM_PLUS",desc:"US '=+' key"},
188:{id:0xBC,ahk:",",win:"VK_OEM_COMMA",desc:"US ',<' key"},
189:{id:0xBD,ahk:"-",win:"VK_OEM_MINUS",desc:"US '-_' key"},
190:{id:0xBE,ahk:".",win:"VK_OEM_PERIOD",desc:"US '.>' key"},
191:{id:0xBF,ahk:"/",win:"VK_OEM_2",desc:"US '/?' key"},
192:{id:0xC0,ahk:"`",win:"VK_OEM_3",desc:"US '`~' key"},
193:{id:0xC1,ahk:"",win:"",desc:_RES},
194:{id:0xC2,ahk:"",win:"",desc:_RES},
195:{id:0xC3,ahk:"",win:"",desc:_RES},
196:{id:0xC4,ahk:"",win:"",desc:_RES},
197:{id:0xC5,ahk:"",win:"",desc:_RES},
198:{id:0xC6,ahk:"",win:"",desc:_RES},
199:{id:0xC7,ahk:"",win:"",desc:_RES},
200:{id:0xC8,ahk:"",win:"",desc:_RES},
201:{id:0xC9,ahk:"",win:"",desc:_RES},
202:{id:0xCA,ahk:"",win:"",desc:_RES},
203:{id:0xCB,ahk:"",win:"",desc:_RES},
204:{id:0xCC,ahk:"",win:"",desc:_RES},
205:{id:0xCD,ahk:"",win:"",desc:_RES},
206:{id:0xCE,ahk:"",win:"",desc:_RES},
207:{id:0xCF,ahk:"",win:"",desc:_RES},
208:{id:0xD0,ahk:"",win:"",desc:_RES},
209:{id:0xD1,ahk:"",win:"",desc:_RES},
210:{id:0xD2,ahk:"",win:"",desc:_RES},
211:{id:0xD3,ahk:"",win:"",desc:_RES},
212:{id:0xD4,ahk:"",win:"",desc:_RES},
213:{id:0xD5,ahk:"",win:"",desc:_RES},
214:{id:0xD6,ahk:"",win:"",desc:_RES},
215:{id:0xD7,ahk:"",win:"",desc:_RES},
216:{id:0xD8,ahk:"",win:"",desc:_UA},
217:{id:0xD9,ahk:"",win:"",desc:_UA},
218:{id:0xDA,ahk:"",win:"",desc:_UA},
219:{id:0xDB,ahk:"[",win:"VK_OEM_4",desc:"US '[{' key"},
220:{id:0xDC,ahk:"\",win:"VK_OEM_5",desc:"US '\|' key"},
221:{id:0xDD,ahk:"]",win:"VK_OEM_6",desc:"US ']}' key"},
222:{id:0xDE,ahk:"",win:"VK_OEM_7",desc:"US 'single-quote/double-quote' key"},
223:{id:0xDF,ahk:"",win:"VK_OEM_8",desc:"OEM #223"},
224:{id:0xE0,ahk:"",win:"",desc:_RES},
225:{id:0xE1,ahk:"",win:"",desc:_OEM},
226:{id:0xE2,ahk:"",win:"VK_OEM_102",desc:"OEM <> or \|"},
227:{id:0xE3,ahk:"",win:"",desc:_OEM},
228:{id:0xE4,ahk:"",win:"",desc:_OEM},
229:{id:0xE5,ahk:"",win:"VK_PROCESSKEY",desc:"IME PROCESS key"},
230:{id:0xE6,ahk:"",win:"",desc:_OEM},
231:{id:0xE7,ahk:"",win:"VK_PACKET",desc:"Unicode characters marker"},
232:{id:0xE8,ahk:"",win:"-",desc:_UA},
233:{id:0xE9,ahk:"",win:"",desc:_OEM},
234:{id:0xEA,ahk:"",win:"",desc:_OEM},
235:{id:0xEB,ahk:"",win:"",desc:_OEM},
236:{id:0xEC,ahk:"",win:"",desc:_OEM},
237:{id:0xED,ahk:"",win:"",desc:_OEM},
238:{id:0xEE,ahk:"",win:"",desc:_OEM},
239:{id:0xEF,ahk:"",win:"",desc:_OEM},
240:{id:0xF0,ahk:"",win:"",desc:_OEM},
241:{id:0xF1,ahk:"",win:"",desc:_OEM},
242:{id:0xF2,ahk:"",win:"",desc:_OEM},
243:{id:0xF3,ahk:"",win:"",desc:_OEM},
244:{id:0xF4,ahk:"",win:"",desc:_OEM},
245:{id:0xF5,ahk:"",win:"",desc:_OEM},
246:{id:0xF6,ahk:"",win:"VK_ATTN",desc:"Attn key"},
247:{id:0xF7,ahk:"",win:"VK_CRSEL",desc:"CrSel key"},
248:{id:0xF8,ahk:"",win:"VK_EXSEL",desc:"ExSel key"},
249:{id:0xF9,ahk:"",win:"VK_EREOF",desc:"Erase EOF key"},
250:{id:0xFA,ahk:"",win:"VK_PLAY",desc:"Play key"},
251:{id:0xFB,ahk:"",win:"VK_ZOOM",desc:"Zoom key"},
252:{id:0xFC,ahk:"",win:"VK_NONAME",desc:"Reserved "},
253:{id:0xFD,ahk:"",win:"VK_PA1",desc:"PA1 key"},
254:{id:0xFE,ahk:"",win:"VK_OEM_CLEAR",desc:"Clear key"}
)}
keyMap := {}
for id, keyObj in _RAW
{
keyMap[id] := keyObj
if (keyObj.ahk)
keyMap[keyObj.ahk] := keyObj
if (keyObj.win)
keyMap[keyObj.win] := keyObj
}
_RAW := "" ; dispose of raw object
return keyMap
}
@girls-incode
Copy link

great!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment