GetKeySC

Retrieves the scan code of a key.

SC := GetKeySC(KeyName)

Parameters

KeyName

Type: String

This can be just about any single character from the keyboard or one of the key names from the key list, such as a mouse/joystick button. Examples: B, 5, LWin, RControl, Alt, Enter, Escape, LButton, MButton, Joy1.

Alternatively, an explicit virtual key code such as vkFF or an explicit scan code such as sc01D may be specified. This is useful in the rare case where a key has no name. The code of such a key can be determined by following the steps at the bottom of the key list page. Note that these codes must be in hexadecimal.

Known limitation: This function cannot differentiate between two keys which share the same virtual key code, such as Left and NumpadLeft.

Return Value

Type: Integer

This function returns the scan code of the specified key.

Remarks

If you want to use the scan code later somewhere else in the script, it must first be converted to hexadecimal format, such as Format("sc{:X}", sc_code).

Related

GetKeyVK, GetKeyName, GetKeyState, Key List, Format

Examples

#1

sc_code := GetKeySC("LControl")
MsgBox Format("sc{:X}", sc_code) ; Shows sc1D