Table of Contents

Key Code Mappings

The following table contains the mapping of virtual key codes defined in the SharpHook.Native.KeyCode enum to OS-specific key code definitions. Note that many key codes are not available on all 3 OSes.

Important

Key code values in the KeyCode enum are meaningless and may change between major versions. Only the enum constant names should be taken into consideration (e.g. when persisting key codes).

Sources:

  • Windows: Microsoft Docs.
  • macOS: HIToolbox/Events.h as defined in macOS 13.5 with some additional key codes included in libuiohook.
  • X11: /usr/share/X11/xkb/keycodes/evdev as defined in Kubuntu 22.04
  • Evdev: input-event-codes.h from the Linux source code.
SharpHook Key Code Windows Key Code macOS Key Code X11 Key Name Evdev Key Definition
VcUndefined Undefined 0xFF Undefined Undefined
VcEscape VK_ESCAPE kVK_Escape ESC KEY_ESC
VcF1 VK_F1 kVK_F1 FK01 KEY_F1
VcF2 VK_F2 kVK_F2 FK02 KEY_F2
VcF3 VK_F3 kVK_F3 FK03 KEY_F3
VcF4 VK_F4 kVK_F4 FK04 KEY_F4
VcF5 VK_F5 kVK_F5 FK05 KEY_F5
VcF6 VK_F6 kVK_F6 FK06 KEY_F6
VcF7 VK_F7 kVK_F7 FK07 KEY_F7
VcF8 VK_F8 kVK_F8 FK08 KEY_F8
VcF9 VK_F9 kVK_F9 FK09 KEY_F9
VcF10 VK_F10 kVK_F10 FK010 KEY_F10
VcF11 VK_F11 kVK_F11 FK011 KEY_F11
VcF12 VK_F12 kVK_F12 FK012 KEY_F12
VcF13 VK_F13 kVK_F13 FK013 KEY_F13
VcF14 VK_F14 kVK_F14 FK014 KEY_F14
VcF15 VK_F15 kVK_F15 FK015 KEY_F15
VcF16 VK_F16 kVK_F16 FK016 KEY_F16
VcF17 VK_F17 kVK_F17 FK017 KEY_F17
VcF18 VK_F18 kVK_F18 FK018 KEY_F18
VcF19 VK_F19 kVK_F19 FK019 KEY_F19
VcF20 VK_F20 kVK_F20 FK020 KEY_F20
VcF21 VK_F21 - FK021 KEY_F21
VcF22 VK_F22 - FK022 KEY_F22
VcF23 VK_F23 - FK023 KEY_F23
VcF24 VK_F24 - FK024 KEY_F24
VcBackQuote VK_OEM_3 kVK_ANSI_Grave TLDE KEY_GRAVE
Vc0 0x30 kVK_ANSI_0 AE10 KEY_0
Vc1 0x31 kVK_ANSI_1 AE01 KEY_1
Vc2 0x32 kVK_ANSI_2 AE02 KEY_2
Vc3 0x33 kVK_ANSI_3 AE03 KEY_3
Vc4 0x34 kVK_ANSI_4 AE04 KEY_4
Vc5 0x35 kVK_ANSI_5 AE05 KEY_5
Vc6 0x36 kVK_ANSI_6 AE06 KEY_6
Vc7 0x37 kVK_ANSI_7 AE07 KEY_7
Vc8 0x38 kVK_ANSI_8 AE08 KEY_8
Vc9 0x39 kVK_ANSI_9 AE09 KEY_9
VcMinus VK_OEM_MINUS kVK_ANSI_Minus AE11 KEY_MINUS
VcEquals VK_OEM_PLUS kVK_ANSI_Equal AE12 KEY_EQUAL
VcBackspace VK_BACK kVK_Delete BKSP KEY_BACKSPACE
VcTab VK_TAB kVK_Tab TAB KEY_TAB
VcCapsLock VK_CAPITAL kVK_CapsLock CAPS KEY_CAPSLOCK
VcA 0x41 kVK_ANSI_A AC01 KEY_A
VcB 0x42 kVK_ANSI_B AB05 KEY_B
VcC 0x43 kVK_ANSI_C AB03 KEY_C
VcD 0x44 kVK_ANSI_D AC03 KEY_D
VcE 0x45 kVK_ANSI_E AD03 KEY_E
VcF 0x46 kVK_ANSI_F AC04 KEY_F
VcG 0x47 kVK_ANSI_G AC05 KEY_G
VcH 0x48 kVK_ANSI_H AC06 KEY_H
VcI 0x49 kVK_ANSI_I AD08 KEY_I
VcJ 0x4A kVK_ANSI_J AC07 KEY_J
VcK 0x4B kVK_ANSI_K AC08 KEY_K
VcL 0x4C kVK_ANSI_L AC09 KEY_L
VcM 0x4D kVK_ANSI_M AB07 KEY_M
VcN 0x4E kVK_ANSI_N AB06 KEY_N
VcO 0x4F kVK_ANSI_O AD09 KEY_O
VcP 0x50 kVK_ANSI_P AD10 KEY_P
VcQ 0x51 kVK_ANSI_Q AD01 KEY_Q
VcR 0x52 kVK_ANSI_R AD04 KEY_R
VcS 0x53 kVK_ANSI_S AC02 KEY_S
VcT 0x54 kVK_ANSI_T AD05 KEY_T
VcU 0x55 kVK_ANSI_U AD07 KEY_U
VcV 0x56 kVK_ANSI_V AB04 KEY_V
VcW 0x57 kVK_ANSI_W AD02 KEY_W
VcX 0x58 kVK_ANSI_X AB02 KEY_X
VcY 0x59 kVK_ANSI_Y AD06 KEY_Y
VcZ 0x5A kVK_ANSI_Z AB01 KEY_Z
VcOpenBracket VK_OEM_4 kVK_ANSI_LeftBracket AD11 KEY_LEFTBRACE
VcCloseBracket VK_OEM_6 kVK_ANSI_RightBracket AD12 KEY_RIGHTBRACE
VcBackslash VK_OEM_5 kVK_ANSI_Backslash AC12 and BKSL KEY_BACKSLASH
VcSemicolon VK_OEM_1 kVK_ANSI_Semicolon AC10 KEY_SEMICOLON
VcQuote VK_OEM_7 kVK_ANSI_Quote AC11 KEY_APOSTROPHE
VcEnter VK_RETURN kVK_Return RTRN KEY_ENTER
VcComma VK_OEM_COMMA kVK_ANSI_Comma AB08 KEY_COMMA
VcPeriod VK_OEM_PERIOD kVK_ANSI_Period AB09 KEY_DOT
VcSlash VK_OEM_2 kVK_ANSI_Slash AB10 KEY_DOT
VcSpace VK_SPACE kVK_Space SPCE KEY_SPACE
Vc102 VK_OEM_102 kVK_ISO_Section LSGT KEY_102ND
VcMisc VK_OEM_8 - - -
VcPrintScreen VK_SNAPSHOT - PRSC KEY_SYSRQ
VcPrint VK_PRINT - I218 KEY_PRINT
VcSelect VK_SELECT - - -
VcExecute VK_EXECUTE - - -
VcScrollLock VK_SCROLL - SCLK KEY_SCROLLLOCK
VcPause VK_PAUSE - PAUS KEY_PAUSE
VcCancel VK_CANCEL - I231 KEY_CANCEL
VcHelp VK_HELP kVK_Help HELP KEY_HELP
VcInsert VK_INSERT - INS KEY_INSERT
VcDelete VK_DELETE kVK_ForwardDelete DELE KEY_DELETE
VcHome VK_HOME kVK_Home HOME KEY_HOME
VcEnd VK_END kVK_End END KEY_END
VcPageUp VK_PRIOR kVK_PageUp PGUP KEY_PAGEUP
VcPageDown VK_NEXT kVK_PageDown PGDN KEY_PAGEDOWN
VcUp VK_UP kVK_UpArrow UP KEY_UP
VcLeft VK_LEFT kVK_LeftArrow LEFT KEY_LEFT
VcRight VK_RIGHT kVK_RightArrow RGHT KEY_RIGHT
VcDown VK_DOWN kVK_DownArrow DOWN KEY_DOWN
VcNumLock VK_NUMLOCK - NMLK KEY_NUMLOCK
VcNumPadClear VK_CLEAR and VK_OEM_CLEAR kVK_ANSI_KeypadClear - -
VcNumPadDivide VK_DIVIDE kVK_ANSI_KeypadDivide KPDV KEY_KPASTERISK
VcNumPadMultiply VK_MULTIPLY kVK_ANSI_KeypadMultiply KPMU KEY_KPSLASH
VcNumPadSubtract VK_SUBTRACT kVK_ANSI_KeypadMinus KPSU KEY_KPMINUS
VcNumPadEquals 0x92 kVK_ANSI_KeypadEquals KPEQ KEY_KPEQUAL
VcNumPadAdd VK_ADD kVK_ANSI_KeypadPlus KPAD KEY_KPPLUS
VcNumPadEnter VK_RETURN with KEYEVENTF_EXTENDEDKEY kVK_ANSI_KeypadEnter KPEN KEY_KPENTER
VcNumPadDecimal VK_DECIMAL kVK_ANSI_KeypadDecimal KPDL KEY_KPDOT
VcNumPadSeparator VK_SEPARATOR - I129 KEY_KPCOMMA
VcNumPadPlusMinus - - I126 KEY_KPPLUSMINUS
VcNumPad0 VK_NUMPAD0 kVK_ANSI_Keypad0 KP0 KEY_KP0
VcNumPad1 VK_NUMPAD1 kVK_ANSI_Keypad1 KP1 KEY_KP1
VcNumPad2 VK_NUMPAD2 kVK_ANSI_Keypad2 KP2 KEY_KP2
VcNumPad3 VK_NUMPAD3 kVK_ANSI_Keypad3 KP3 KEY_KP3
VcNumPad4 VK_NUMPAD4 kVK_ANSI_Keypad4 KP4 KEY_KP4
VcNumPad5 VK_NUMPAD5 kVK_ANSI_Keypad6 KP6 KEY_KP6
VcNumPad6 VK_NUMPAD6 kVK_ANSI_Keypad6 KP6 KEY_KP6
VcNumPad7 VK_NUMPAD7 kVK_ANSI_Keypad7 KP7 KEY_KP7
VcNumPad8 VK_NUMPAD8 kVK_ANSI_Keypad8 KP8 KEY_KP8
VcNumPad9 VK_NUMPAD9 kVK_ANSI_Keypad9 KP9 KEY_KP9
VcNumPadOpenParenthesis - - I187 KEY_KPLEFTPAREN
VcNumPadCloseParenthesis - - I188 KEY_KPRIGHTPAREN
VcLeftShift VK_LSHIFT and VK_SHIFT kVK_Shift LFSH KEY_LEFTSHIFT
VcRightShift VK_RSHIFT kVK_RightShift RTSH KEY_RIGHTSHIFT
VcLeftControl VK_LCONTROL and VK_CONTROL kVK_Control LCTL KEY_LEFTCTRL
VcRightControl VK_RCONTROL kVK_RightControl RCTL KEY_RIGHTCTRL
VcLeftAlt VK_LMENU and VK_MENU kVK_Option LALT KEY_LEFTALT
VcRightAlt VK_RMENU kVK_RightOption RALT KEY_RIGHTALT
VcLeftMeta VK_LWIN kVK_Command LWIN and LMTA KEY_LEFTMETA
VcRightMeta VK_RWIN kVK_RightCommand RWIN and RMTA KEY_RIGHTMETA
VcContextMenu VK_APPS 0x6E COMP and MENU KEY_COMPOSE
VcFunction - kVK_Function - -
VcChangeInputSource - 0xB3 - -
VcPower - 0xE6 POWR KEY_POWER
VcSleep VK_SLEEP - I150 KEY_SLEEP
VcWake - - I151 KEY_WAKEUP
VcMedia - - I234 KEY_MEDIA
VcMediaPlay VK_MEDIA_PLAY_PAUSE 0xF0 I172 KEY_PLAYPAUSE
VcMediaStop VK_MEDIA_STOP - I174 KEY_STOPCD
VcMediaPrevious VK_MEDIA_PREV_TRACK 0xF2 I173 KEY_PREVIOUSSONG
VcMediaNext VK_MEDIA_NEXT_TRACK 0xF1 I171 KEY_NEXTSONG
VcMediaSelect VK_LAUNCH_MEDIA_SELECT - - -
VcMediaEject - 0xEE I169 KEY_EJECTCD
VcMediaClose - - I168 KEY_CLOSECD
VcMediaEjectClose - - I170 KEY_EJECTCLOSECD
VcMediaRecord - - I175 KEY_RECORD
VcMediaRewind - - I176 KEY_REWIND
VcVolumeMute VK_VOLUME_MUTE kVK_Mute MUTE KEY_MUTE
VcVolumeDown VK_VOLUME_DOWN kVK_VolumeDown VOL- KEY_VOLUMEDOWN
VcVolumeUp VK_VOLUME_UP kVK_VolumeUp VOL+ KEY_VOLUMEUP
VcAttn VK_ATTN - - -
VcCrSel VK_CRSEL - - -
VcExSel VK_EXSEL - - -
VcEraseEof VK_EREOF - - -
VcPlay VK_PLAY - I215 KEY_PLAY
VcZoom VK_ZOOM - - -
VcNoName VK_NONAME - - -
VcPa1 VK_PA1 - - -
VcApp1 VK_LAUNCH_APP1 - I156 KEY_PROG1
VcApp2 VK_LAUNCH_APP2 - I157 KEY_PROG2
VcApp3 - - I210 KEY_PROG3
VcApp4 - - I211 KEY_PROG4
VcAppBrowser - - I158 KEY_WWW
VcAppCalculator - - I148 KEY_CALC
VcAppMail VK_LAUNCH_MAIL - I163 KEY_MAIL
VcBrowserSearch VK_BROWSER_SEARCH - I225 KEY_SEARCH
VcBrowserHome VK_BROWSER_HOME - I180 KEY_HOMEPAGE
VcBrowserBack VK_BROWSER_BACK - I166 KEY_BACK
VcBrowserForward VK_BROWSER_FORWARD - I167 KEY_FORWARD
VcBrowserStop VK_BROWSER_STOP - - -
VcBrowserRefresh VK_BROWSER_REFRESH - I181 KEY_REFRESH
VcBrowserFavorites VK_BROWSER_FAVORITES - I164 KEY_BOOKMARKS
VcKatakanaHiragana - - HKTG KEY_KATAKANAHIRAGANA
VcKatakana - - KATA KEY_KATAKANA
VcHiragana - - HIRA KEY_HIRAGANA
VcKana VK_KANA kVK_JIS_Kana - -
VcKanji VK_KANJI - - -
VcHangul VK_HANGUL - HNGL KEY_HANGEUL
VcJunja VK_JUNJA - - -
VcFinal VK_FINAL - - -
VcHanja VK_HANJA - HJCV KEY_HANJA
VcAccept VK_ACCEPT - - -
VcConvert VK_CONVERT - HENK KEY_HENKAN
VcNonConvert VK_NONCONVERT - MUHE KEY_MUHENKAN
VcImeOn VK_IME_ON - - -
VcImeOff VK_IME_OFF - - -
VcModeChange VK_MODECHANGE - I155 KEY_XFER
VcProcess VK_PROCESSKEY - - -
VcAlphanumeric - kVK_JIS_Eisu - -
VcUnderscore - kVK_JIS_Underscore AB11 KEY_RO
VcYen - kVK_JIS_Yen AE13 KEY_YEN
VcJpComma - kVK_JIS_KeypadComma JPCM KEY_KPJPCOMMA
VcStop - - STOP and I136 KEY_STOP
VcProps - - PROP and I138 KEY_PROPS
VcFront - - FRNT and I140 KEY_FRONT
VcOpen - - OPEN and I142 KEY_OPEN
VcFind - - FIND and I144 KEY_FIND
VcAgain - - AGAI and I137 KEY_AGAIN
VcUndo - - UNDO and I139 KEY_UNDO
VcRedo - - I190 KEY_REDO
VcCopy - - COPY and I141 KEY_COPY
VcPaste - - PAST and I143 KEY_PASTE
VcCut - - CUT and I145 KEY_CUT
VcLineFeed - - LNFD KEY_LINEFEED
VcMacro - - I120 KEY_MACRO
VcScale - - I128 KEY_SCALE
VcSetup - - I149 KEY_SETUP
VcFile - - I152 KEY_FILE
VcSendFile - - I153 KEY_SENDFILE
VcDeleteFile - - I154 KEY_DELETEFILE
VcMsDos - - I159 KEY_MSDOS
VcLock - - I160 KEY_COFFEE
VcRotateDisplay - - I161 KEY_ROTATE_DISPLAY
VcCycleWindows - - I162 KEY_CYCLEWINDOWS
VcComputer - - I165 KEY_COMPUTER
VcPhone - - I177 KEY_PHONE
VcIso - - I178 KEY_ISO
VcConfig - - I179 KEY_CONFIG
VcExit - - I182 KEY_EXIT
VcMove - - I183 KEY_MOVE
VcEdit - - I184 KEY_EDIT
VcScrollUp - - I185 KEY_SCROLLUP
VcScrollDown - - I186 KEY_SCROLLDOWN
VcNew - - I189 KEY_NEW
VcPlayCd - - I208 KEY_PLAYCD
VcPauseCd - - I209 KEY_PAUSECD
VcDashboard - - I212 KEY_DASHBOARD
VcSuspend - - I213 KEY_SUSPEND
VcClose - - I214 KEY_CLOSE
VcFastForward - - I216 KEY_FASTFORWARD
VcBassBoost - - I217 KEY_BASSBOOST
VcHp - - I219 KEY_HP
VcCamera - - I220 KEY_CAMERA
VcSound - - I221 KEY_SOUND
VcQuestion - - I222 KEY_QUESTION
VcEmail - - I223 KEY_EMAIL
VcChat - - I224 KEY_CHAT
VcConnect - - I226 KEY_CONNECT
VcFinance - - I227 KEY_FINANCE
VcSport - - I228 KEY_SPORT
VcShop - - I229 KEY_SHOP
VcAltErase - - I230 KEY_ALTERASE
VcBrightnessDown - - I232 KEY_BRIGHTNESSDOWN
VcBrightnessUp - - I233 KEY_BRIGHTNESSUP
VcBrightnesCycle - - I251 KEY_BRIGHTNESS_CYCLE
VcBrightnessAuto - - I252 KEY_BRIGHTNESS_AUTO
VcSwitchVideoMode - - I235 KEY_SWITCHVIDEOMODE
VcKeyboardLightToggle - - I236 KEY_KBDILLUMTOGGLE
VcKeyboardLightDown - - I237 KEY_KBDILLUMDOWN
VcKeyboardLightUp - - I238 KEY_KBDILLUMUP
VcSend - - I239 KEY_SEND
VcReply - - I240 KEY_REPLY
VcForwardMail - - I241 KEY_FORWARDMAIL
VcSave - - I242 KEY_SAVE
VcDocuments - - I243 KEY_DOCUMENTS
VcBattery - - I244 KEY_BATTERY
VcBluetooth - - I245 KEY_BLUETOOTH
VcWlan - - I246 KEY_WLAN
VcUwb - - I247 KEY_UWB
VcX11Unknown - - I248 KEY_UNKNOWN
VcVideoNext - - I249 KEY_VIDEO_NEXT
VcVideoPrevious - - I250 KEY_VIDEO_PREV
VcVideoPrevious - - I250 KEY_VIDEO_PREV
VcDisplayOff - - I253 KEY_DISPLAY_OFF
VcWwan - - I254 KEY_WWAN
VcRfKill - - I255 KEY_RFKILL