zmk/docs/docs/keymaps/behaviors/key-press.md

2.1 KiB

title sidebar_label
Key Press Behaviors Key Press

Summary

The most basic of behaviors, is the ability to send certain keycode presses and releases in response to activating a certain key.

The categories of supported keycodes are:

For advanced users, user-defined HID usages are also supported but must be encoded, please see dt-bindings/zmk/keys.h for further insight.

Keycode Defines

To make it easier to encode the HID keycode numeric values, most keymaps include the dt-bindings/zmk/keys.h header provided by ZMK near the top:

#include <dt-bindings/zmk/keys.h>

Doing so makes a set of defines such as A, N1, etc. available for use with these behaviors

Key Press

The "key press" behavior sends standard keycodes on press/release.

Behavior Binding

  • Reference: &kp
  • Parameter: The keycode usage ID from the usage page, e.g. N4 or A

Example:

&kp A

Key Tap

The "key tap" behavior will send a press followed by a release when you press the behavior, and will do nothing when you release the behavior.

Behavior Binding

  • Reference: &ktap
  • Parameter: The keycode usage ID from the usage page, e.g. N4 or A

Example:

&ktap A

Configuration

You can adjust the tap duration, i.e. the time between press and release of the key, by changing the tap-ms property:

&ktap {
    tap-ms = <30>; // This is the value already set by default
};

:::info Internally, the key tap behavior is a very simple macro. :::