<!-- Source: https://medius.k4tech.net/native/commands/usage -->
# Usage IDs

_The id numbers inject and lock take_

[`INJECT`](/native/commands/inject.md#inject) and [`LOCK`](/native/commands/lock.md#lock) both name an input by an `id`, and the numbers depend on the class: a [button id](/native/commands/usage.md#buttons) for the mouse, a [HID keyboard usage](/native/commands/usage.md#keycodes) for a key, or a 16-bit [Consumer usage](/native/commands/usage.md#consumer) for a media key. They're gathered here so the command pages stay short.

## Button ids

_Mouse buttons (class = button)_

A small semantic id, bound at clone time to the real mouse's buttons, and the same id for [`INJECT`](/native/commands/inject.md#button) and [`LOCK`](/native/commands/lock.md#lock) (a button locks as `class = 0`, `id = button id`, the same `(class, id)` form a key or media usage takes). A command for an id the mouse lacks is a no-op, so read [`CAPS`](/native/commands/requests.md#caps) `n_buttons` first.

| Button | `id` |
| --- | --- |
| Left | `0` |
| Right | `1` |
| Middle | `2` |
| Side1 (first thumb) | `3` |
| Side2 (second thumb) | `4` |

The Rust library exposes these as the named [`Button`](/library/types/enums.md#button) enum (`Button::Left`, `Button::Side2`, ...).

## HID keyboard usages

_Keys and modifiers (class = key)_

The `id` is a HID Keyboard/Keypad usage from the [USB HID Usage Tables](https://www.usb.org/sites/default/files/hut1_5.pdf) (page 0x07). A usage of `0xE0`\-`0xE7` is a modifier and folds into the modifier byte; any other usage fills a keycode slot. The common ones:

| Key | Usage |
| --- | --- |
| `A` .. `Z` | `0x04` .. `0x1D` |
| `1` .. `9` | `0x1E` .. `0x26` |
| `0` | `0x27` |
| Enter / Escape / Backspace / Tab | `0x28` / `0x29` / `0x2A` / `0x2B` |
| Space | `0x2C` |
| Caps Lock | `0x39` |
| `F1` .. `F12` | `0x3A` .. `0x45` |
| Insert / Home / Page Up | `0x49` / `0x4A` / `0x4B` |
| Delete / End / Page Down | `0x4C` / `0x4D` / `0x4E` |
| Right / Left / Down / Up | `0x4F` / `0x50` / `0x51` / `0x52` |

#### MODIFIERS

| Modifier | Usage |
| --- | --- |
| Left Ctrl / Shift / Alt / GUI | `0xE0` / `0xE1` / `0xE2` / `0xE3` |
| Right Ctrl / Shift / Alt / GUI | `0xE4` / `0xE5` / `0xE6` / `0xE7` |

The Rust library exposes these as named [`Key`](/library/types/structs.md#key) constants (`Key::A`, `Key::LEFT_SHIFT`, ...).

## Consumer usages

_Media keys (class = media)_

The `id` is a 16-bit usage from the Consumer page (0x0C) of the [USB HID Usage Tables](https://www.usb.org/sites/default/files/hut1_5.pdf). Present-gated to a board with a Consumer collection, read from the [`CAPS`](/native/commands/requests.md#caps) `CONSUMER` flag. The usual transport controls:

| Media key | Usage |
| --- | --- |
| Play / Pause toggle | `0x00CD` |
| Play | `0x00B0` |
| Pause | `0x00B1` |
| Stop | `0x00B7` |
| Next track | `0x00B5` |
| Previous track | `0x00B6` |
| Mute | `0x00E2` |
| Volume up | `0x00E9` |
| Volume down | `0x00EA` |

The Rust library exposes these as named [`MediaKey`](/library/types/structs.md#media-key) constants (`MediaKey::VOLUME_UP`, ...).
