LinuxCommandLibrary

keyd

Remap keyboard keys and create macros

TLDR

Start and enable the keyd service

$ systemctl enable keyd --now
copy

Display keypress information
$ sudo keyd [[-m|monitor]]
copy

Reset bindings and reload the configuration files in /etc/keyd
$ sudo keyd reload
copy

List all valid key names
$ keyd list-keys
copy

Check the detected configuration files for errors
$ keyd check
copy

Create a temporary binding
$ sudo keyd bind "[pressed_key] = [output_key]"
copy

SYNOPSIS

keyd [OPTIONS] | keyd [SUBOPTIONS]

PARAMETERS

-c, --config PATH
    Specify alternative config file path (default: /etc/keyd/default.conf)

-s, --socket PATH
    Runtime control socket path (default: /run/keyd/socket)

-l, --log-level LEVEL
    Set logging verbosity: off|error|info|debug

-d, --daemonize
    Daemonize after startup (default behavior)

-u, --user USER
    Drop root privileges to USER after binding devices

-m, --mode MODE
    Input mode: auto|xi1|evdev|fallback (auto-detects)

-h, --help
    Display help and exit

reload
    Reload configuration without restarting daemon

monitor
    Monitor and print key events in real-time

status
    Print daemon status and active layer

DESCRIPTION

keyd is a keyboard daemon for Linux that enables complex, stateful key remapping and macro definitions. Unlike traditional tools like xmodmap or setxkbmap, keyd supports layered layouts, where keys change behavior based on single modifiers, key sequences, or timeouts. It intercepts keyboard events at a low level via libinput or evdev, allowing overrides for any key without altering the base XKB layout.

Primarily designed for gaming keyboards and power users, keyd shines in handling combos like hyper+key layers or mouse button emulation from keys. It works seamlessly on both X11 and Wayland, daemonizing as root to grab /dev/input/* devices. Configuration is done via a simple keyd.conf file with sections for layers and fallbacks.

keyd avoids polling by hooking into input subsystems, ensuring low latency. It's lightweight, with no persistent state beyond the runtime socket for runtime controls like reload.

CAVEATS

Requires root privileges to access input devices; may conflict with other input daemons like Plasma's kwin_wayland. Not compatible with udev hwdb rules for custom keyboards. On some systems, needs logind inhibit or systemd service for persistence.

CONFIGURATION EXAMPLE

[ids] * [main] capslock = overload(control, escape) touchpad = toggle [control] touchpad = mouse Install via: make && sudo make install

HISTORY

Developed by rvaiya starting in 2020 on GitHub as a response to libinput's limitations on modifier taps and combos. Initial release v1.0.0 in 2021; now at v2.x with Wayland/evdev backend improvements and macro scripting.

SEE ALSO

xmodmap(1), setxkbmap(1), loadkeys(8), evtest(1)

Copied to clipboard