GetKeyName() / GetKeyVK() / GetKeySC() [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)

Parameters

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 the name, virtual key code or scan code of Key.

GetKeyState, Key List, Format()

Examples

Reports 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)