โŒจ๏ธ BLE Keyboard Keycodes

espidf_ble_keyboard ยท ESPHome Component Reference

๐Ÿ’ก Looking for named actions? sleep shutdown mute volume_up play_pause and more are documented in the README.
Syntax
action: "combo:<modifier_hex>:<keycode_hex>"

"combo:0x00:0x04" # tap 'a'
"combo:0x02:0x04" # shift + a โ†’ 'A'
"combo:0x08:0x15" # Win + R (Run dialog)
"combo:0x01:0x06" # Ctrl + C (Copy)
"Hello World" # type a string directly
"ctrl_alt_del" # built-in shortcut

Modifier Keys

ModifierHex
None0x00
Left Ctrl0x01
Left Shift0x02
Left Alt0x04
Left GUI / Win / Cmd0x08
Right Ctrl0x10
Right Shift0x20
Right Alt / AltGr0x40
Right GUI / Win / Cmd0x80
Combine by adding values: Ctrl+Shift = 0x01+0x02 = 0x03

Function Keys

KeyHexKeyHex
F10x3AF70x40
F20x3BF80x41
F30x3CF90x42
F40x3DF100x43
F50x3EF110x44
F60x3FF120x45
F130x68F190x6E
F140x69F200x6F
F150x6AF210x70
F160x6BF220x71
F170x6CF230x72
F180x6DF240x73
Example: Alt+F4 = combo:0x04:0x3D · F13–F24 make ideal macro keys (unused by Windows apps by default). Re-pair the device after updating from firmware without F13–F24 support — hosts cache the HID descriptor per bond.

Letter Keys Aโ€“Z

KeyCodeKeyCodeKeyCode
a / A0x04j / J0x0Ds / S0x16
b / B0x05k / K0x0Et / T0x17
c / C0x06l / L0x0Fu / U0x18
d / D0x07m / M0x10v / V0x19
e / E0x08n / N0x11w / W0x1A
f / F0x09o / O0x12x / X0x1B
g / G0x0Ap / P0x13y / Y0x1C
h / H0x0Bq / Q0x14z / Z0x1D
i / I0x0Cr / R0x15
Uppercase: add modifier 0x02 (Left Shift). e.g. combo:0x02:0x04 = A

Number Keys 0โ€“9

KeyCodeShifted
10x1E!
20x1F@
30x20#
40x21$
50x22%
60x23^
70x24&
80x25*
90x26(
00x27)

Special & Navigation Keys

KeyCodeKeyCode
Enter0x28Up Arrow0x52
Escape0x29Down Arrow0x51
Backspace0x2ALeft Arrow0x50
Tab0x2BRight Arrow0x4F
Space0x2CInsert0x49
Caps Lock0x39Delete (Fwd)0x4C
Print Screen0x46Home0x4A
Scroll Lock0x47End0x4D
Pause / Break0x48Page Up0x4B
Menu / App0x65Page Down0x4E

Punctuation & Symbols

KeyCodeShifted
- / _0x2D_
= / +0x2E+
[ / {0x2F{
] / }0x30}
\ / |0x31|
; / :0x33:
' / "0x34"
` / ~0x35~
, / <0x36<
. / >0x37>
/ / ?0x38?

Numpad Keys

KeyCodeKeyCode
Numpad 00x62Numpad 60x5E
Numpad 10x59Numpad 70x5F
Numpad 20x5ANumpad 80x60
Numpad 30x5BNumpad 90x61
Numpad 40x5CNumpad .0x63
Numpad 50x5DNumpad Enter0x58
Numpad +0x57Numpad -0x56
Numpad *0x55Numpad /0x54
Num Lock0x53

Common Shortcuts

Actionaction: value
Win + R (Run)combo:0x08:0x15
Win + L (Lock)combo:0x08:0x0F
Win + D (Desktop)combo:0x08:0x07
Win + E (Explorer)combo:0x08:0x08
Ctrl + C (Copy)combo:0x01:0x06
Ctrl + V (Paste)combo:0x01:0x19
Ctrl + Z (Undo)combo:0x01:0x1D
Ctrl + A (Select All)combo:0x01:0x04
Alt + F4 (Close)combo:0x04:0x3D
Alt + Tab (Switch)combo:0x04:0x2B
Ctrl+Shift+Esc (Tasks)combo:0x03:0x29
Ctrl + Alt + Delctrl_alt_del

Consumer Control Codes โ€” consumer:0x0192

Application Launch
AppCode
Calculator0x0192
Email Client0x018A
File Explorer0x0194
Media Player0x0183
Browser Home0x0223
Browser Search0x0221
Browser Bookmarks0x022A
Screen Saver0x019E
Control Panel0x019F
Task Manager0x01A9
Media & Volume
ActionCode
Play / Pause0x00CD
Stop0x00B7
Record0x00B2
Next Track0x00B5
Previous Track0x00B6
Mute0x00E2
Volume Up0x00E9
Volume Down0x00EA
Fast Forward0x00B3
Rewind0x00B4
Brightness Up0x006F
Brightness Down0x0070
Use named actions for power: sleep, shutdown, hibernate are more reliable than consumer codes for system power.

Mouse Actions โ€” Report ID 4 + 5

Named Actions
ActionValue
Left Clickleft_click
Right Clickright_click
Middle Clickmiddle_click
Save abs. positionmouse_abs_save
Restore abs. positionmouse_abs_restore
Parameterised Actions
FormatExample
Click by maskmouse_click:0x01
Move cursor (relative)mouse_move:50:-20
Scroll wheelmouse_scroll:3
Move to % of screenmouse_abs:50:50
Move to pixelsmouse_abs_px:1280:720
Move within monitormouse_abs_mon:1:50:50
Goto desktop pixel (all monitors)mouse_goto:4394:42
Button mask: 0x01 = left, 0x02 = right, 0x04 = middle. Combine for simultaneous buttons. Relative move/scroll: -127 to 127. Absolute (mouse_abs*, Report ID 5) moves the cursor to an exact spot โ€” percent of screen, pixels (uses screen_width/screen_height), or within a declared monitors[] region; Windows often confines it to the primary monitor. Reliable on Windows/Linux; best-effort on macOS/iOS. After flashing, re-pair the host or absolute moves do nothing.
mouse_goto reaches every monitor (homes to the desktop origin, then steps relatively) โ€” feed it Windows desktop coords (read a spot's with the bundled docs/cursorpos.bat). For accuracy: turn Enhance pointer precision off and set the pointer-speed slider to a fixed position, then calibrate to it (moving it even one notch loses accuracy), set per-axis mouse_goto_scale_x/mouse_goto_scale_y, and mark the primary screen with primary: true. Easiest to calibrate live in the web Position Finder, which saves the scale per host.

Host Switching

ActionDescription
switch_host:0Switch to host slot 0โ€“9. Reconnects via directed advertising or advertises for new pairing.
switch_host:nextStep one slot forward (or switch_host:prev for back), wrapping at the ends. Empty slots are included in the rotation.
switch_host:backReturn to the slot that was active before the last switch, however it was made. Pressed again, it goes back again.
prev_host / next_host / last_hostThe same three as remote keys a style can place, remappable per host.
next_keyboard / prev_host_all / next_host_allWeb page remote only: move the tab to the next linked keyboard, or through every host of every linked keyboard.
keyboard / typing / touchpadRemote keys, on the web page and the Home Assistant remote card: open the on-screen keyboard under the remote, a box your phone's or PC's own keyboard types into, or a mouse pad.
screen_search / screen_search:<name>A remote key: opens the search screen of the app the host was last sent to and has text spelled on that app's own on-screen keys from then on. Needs a screen keyboard for the app (Host Actions); without one it is search.
screen_keys:<name> / screen_keys:offStart spelling on a screen keyboard where the app already is, or stop.
group:<name>A remote key, on the web page and the Home Assistant remote card: opens one of the style's groups of keys over the remote.
peer:<name>:<action>Run an action on a linked keyboard listed under peers: โ€” peer:bedroom:switch_host:1.
caps_lock:on / caps_lock:off / caps_lock:toggleSet the host's Caps Lock: on and off tap it only when the host reports it the other way, then wait for the host to confirm.
wait:connectedHold a macro until the active host is ready for keys, up to 10 s โ€” wait:connected:N for N ms (max 60000). On timeout the macro carries on.
forget_host:0Remove BLE bond for host slot 0โ€“9 and clear the stored address.
advertise:4:offTurn host slot 4's Bluetooth off (on, toggle), as the Host Actions tick does. Without the slot, the active host's.
Up to 10 host slots. Paired hosts are stored in NVS and persist across reboots. Dict format: type: switch_host, slot: 1 โ€” or slot: next, prev, back.

YAML Button Example

button:
  - platform: espidf_ble_keyboard
    keyboard_id: ble_keyboard
    name: "Open Run Dialog"
    action: "combo:0x08:0x15"     # Win + R

  - platform: espidf_ble_keyboard
    keyboard_id: ble_keyboard
    name: "Type Hello"
    action: "Hello World"           # send a string directly

  - platform: espidf_ble_keyboard
    keyboard_id: ble_keyboard
    name: "Left Click"
    action: "left_click"            # mouse left click

  - platform: espidf_ble_keyboard
    keyboard_id: ble_keyboard
    name: "Cursor to Center"
    action: "mouse_abs:50:50"       # exact position, % of screen

  - platform: espidf_ble_keyboard
    keyboard_id: ble_keyboard
    name: "Ctrl+Alt+Del"
    action: "ctrl_alt_del"          # built-in action

  - platform: espidf_ble_keyboard
    keyboard_id: ble_keyboard
    name: "Ctrl+Shift+A"
    action: "combo:0x03:0x04"     # 0x01+0x02=0x03 (Ctrl+Shift), 0x04=A