Skip to content

Key constants#

Constants for the SendKeyPress, SendKeyDown, SendKeyUp functions (keyboard functions) and for the modifiers parameter of the click and mouse-move functions (click and mouse functions).

Key combinations#

Modifier keys (Ctrl, Shift, Alt, Command) are held down together with the main key or mouse button. Combine several keys with the | operator, for example WITH_CTRL | WITH_SHIFT.

Constant Value Meaning
WITH_ALT 1 Hold Alt
WITH_CTRL 2 Hold Ctrl
WITH_COMMAND 4 Hold Meta (Command on macOS, the Windows key on Windows)
WITH_SHIFT 8 Hold Shift

Key codes#

Each K_* constant stands for one key and is used as the keyCode parameter.

Constant Key code
K_BACKSPACE 8
K_TAB 9
K_ENTER 13
K_SHIFT 16
K_CONTROL 17
K_ALT 18
K_PAUSE 19
K_CAPSLOCK 20
K_ESCAPE 27
K_SPACE 32
K_PAGEUP 33
K_PAGEDOWN 34
K_END 35
K_HOME 36
K_ARROWLEFT 37
K_ARROWUP 38
K_ARROWRIGHT 39
K_ARROWDOWN 40
K_PRINTSCREEN 44
K_INSERT 45
K_DELETE 46
K_DIGIT0 48
K_DIGIT1 49
K_DIGIT2 50
K_DIGIT3 51
K_DIGIT4 52
K_DIGIT5 53
K_DIGIT6 54
K_DIGIT7 55
K_DIGIT8 56
K_DIGIT9 57
K_KEYA 65
K_KEYB 66
K_KEYC 67
K_KEYD 68
K_KEYE 69
K_KEYF 70
K_KEYG 71
K_KEYH 72
K_KEYI 73
K_KEYJ 74
K_KEYK 75
K_KEYL 76
K_KEYM 77
K_KEYN 78
K_KEYO 79
K_KEYP 80
K_KEYQ 81
K_KEYR 82
K_KEYS 83
K_KEYT 84
K_KEYU 85
K_KEYV 86
K_KEYW 87
K_KEYX 88
K_KEYY 89
K_KEYZ 90
K_METALEFT 91
K_METARIGHT 92
K_CONTEXTMENU 93
K_NUMPAD0 96
K_NUMPAD1 97
K_NUMPAD2 98
K_NUMPAD3 99
K_NUMPAD4 100
K_NUMPAD5 101
K_NUMPAD6 102
K_NUMPAD7 103
K_NUMPAD8 104
K_NUMPAD9 105
K_NUMPADMULTIPLY 106
K_NUMPADADD 107
K_NUMPADSUBTRACT 109
K_NUMPADDECIMAL 110
K_NUMPADDIVIDE 111
K_F1 112
K_F2 113
K_F3 114
K_F4 115
K_F5 116
K_F6 117
K_F7 118
K_F8 119
K_F9 120
K_F10 121
K_F11 122
K_F12 123
K_NUMLOCK 144
K_SCROLLLOCK 145
K_AUDIOVOLUMEMUTE 173
K_AUDIOVOLUMEDOWN 174
K_AUDIOVOLUMEUP 175
K_MEDIATRACKNEXT 176
K_MEDIATRACKPREVIOUS 177
K_MEDIASTOP 178
K_MEDIAPLAYPAUSE 179
K_LAUNCHMAIL 180
K_LAUNCHMEDIAPLAYER 181
K_LAUNCHAPPLICATION1 182
K_LAUNCHAPPLICATION2 183
K_SEMICOLON 186
K_EQUAL 187
K_COMMA 188
K_MINUS 189
K_PERIOD 190
K_SLASH 191
K_BACKQUOTE 192
K_BRACKETLEFT 219
K_BACKSLASH 220
K_BRACKETRIGHT 221
K_QUOTE 222

Combined example#

Type a keyword into the search box, select all its content with Ctrl + A, type over it, then press Enter:

await ClickBySelector('input[type="search"]');
await Typing("9hits");

// Ctrl + A: select all content in the input box
await SendKeyDown(K_KEYA, WITH_CTRL);
await SendKeyUp(K_KEYA, WITH_CTRL);

await Typing("9hits traffic exchange");
await SendKeyPress(K_ENTER); // press Enter to submit