Browse the docs

USB device key

Runs the macro when a key or button on a USB device such as a keypad or macro pad is pressed.

key is pressed on device

Keyboard Maestro: HID, USB Device Key

Details #

Watches every connected input device (keyboards, keypads, pedals, buttons) and fires when a key on one is pressed. This is how you give a second keypad its own job, separate from your main keyboard.

device limits it to one product. It matches if the product name the device reports contains the text (any case), for example Keypad. Left out, any device matches.

key names the key by its HID usage, written as page:usage in two-digit hex. Page 07 is the keyboard page, so 07:04 is the A key, 07:05 is B and 07:28 is Return. Any case works. If you leave key out, any key on the matching device fires the macro.

Only presses fire: an input counts when its value is not zero, so a key coming back up is ignored. Vendor-specific controls on page FF00 are skipped.

The device's keys still do whatever they normally do. This trigger watches them; it does not swallow them.

{{triggerValue}} is empty for this trigger.

Parameters #

ParameterTypeRequiredValuesWhat it does
devicetextText that must appear in the device's product name. Optional.
keytextThe key as page:usage hex, such as 07:04. Optional.

Every trigger also takes Limits: a cooldown, the first time each day, every nth time, twice within seconds, a chance, only while you are at the Mac, on one Mac, or in a State. See Limits on any trigger.

Examples #

Show which device pressed A
When
  1. Key 07:04 is pressed on “Keypad”
Do
  1. Show “A pressed on the keypad”
Open in Switchboard to try it

Gotchas #

  • The source opens only once a macro has a hid trigger.

  • With no key, every non-zero input from a matching device counts, not only keys. Mice and trackpads report movement the same way, so set key or a device that is not one.

  • A key that is not in page:usage hex form never matches. The page and usage are the HID numbers, not key codes or letters.

  • A key that your main keyboard also has (like A) fires only for the device you name when you set device. Without it, your main keyboard's A fires the macro too.

  • Pressing a key may still type into the front app. Pair it with an Only if condition, or use a keypad that sends keys you never use.

See also #

MIDI message, Hotkey, Device attach or detach