GetKeyName/VK/SC() [v1.1.01+]

Retrieves the name/text, virtual key code or scan code of a key.

String := GetKeyName(Key)
Number := GetKeyVK(Key)
Number := GetKeySC(Key)



A VK or SC code, such as "vkA2" or "sc01D", a combination of both, or a key name. For example, both GetKeyName("vk1B") and GetKeyName("Esc") return "Escape", while GetKeyVK("Esc") returns 27. Note that VK and SC codes must be in hexadecimal. To convert a decimal number to the appropriate format, use Format("vk{:x}", vk_code) or Format("sc{:x}", sc_code).

Return Value

These functions return a name, virtual key code or scan code of Key.


GetKeyState, Key List, Format


; Show information for a specific key.
key  := "lwin" ; Any key can be used here.

name := GetKeyName(key)
vk   := GetKeyVK(key)
sc   := GetKeySC(key)

MsgBox, % Format("Name:`t{}`nVK:`t{:X}`nSC:`t{:X}", name, vk, sc)