Scripts2026年7月17日·1 分钟阅读

kanata — Advanced Cross-Platform Keyboard Remapping

Software keyboard remapper for Linux, macOS, and Windows that supports layers, tap-hold, macros, and mouse emulation — all configured via a text file.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 66/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
kanata Overview
先审查命令
npx -y tokrepo@latest install 130abbdf-81dd-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

Introduction

kanata is a cross-platform software keyboard remapper written in Rust. It intercepts keyboard input at the OS level and transforms it according to rules defined in a text configuration file, enabling features like layers, tap-hold dual-function keys, and mouse emulation — all without flashing firmware.

What kanata Does

  • Remaps any key to any other key, modifier, or action across all applications
  • Supports tap-hold keys that send one keycode on tap and another when held
  • Implements multiple keyboard layers switchable via dedicated keys
  • Emulates mouse movement and clicks from the keyboard
  • Runs as a background process with hot-reloadable configuration

Architecture Overview

kanata is a single Rust binary that hooks into the OS input system: on Linux it reads from /dev/input and writes to a virtual uinput device, on Windows it uses the Interception driver or a low-level keyboard hook, and on macOS it uses the IOKit HID framework. Input events pass through a state machine that evaluates the current layer, pending tap-hold timers, and macro sequences before emitting transformed events.

Self-Hosting & Configuration

  • Install via cargo or download prebuilt binaries for Linux, macOS, and Windows
  • Configuration uses a Lisp-inspired .kbd text format for defining layers and key behaviors
  • On Windows, the Interception driver provides the most reliable input interception
  • Hot-reload support: edit the config file and kanata picks up changes without restarting
  • Run at startup via systemd (Linux), launchd (macOS), or Task Scheduler (Windows)

Key Features

  • True cross-platform support with native input interception on each OS
  • Tap-hold, tap-dance, one-shot, and combo key behaviors
  • Unlimited layers with transparent and blocked key pass-through
  • Built-in mouse emulation for keyboard-driven cursor movement
  • Live config reload without dropping any keystrokes

Comparison with Similar Tools

  • QMK/ZMK — firmware-level remapping for specific keyboards; kanata works with any keyboard
  • kmonad — similar concept in Haskell; kanata offers broader OS support and active development
  • AutoHotkey — Windows-only scripting tool; kanata is cross-platform and purpose-built for remapping
  • Karabiner-Elements — macOS-only; kanata works on Linux, macOS, and Windows
  • xremap — Linux-only; kanata adds Windows and macOS support

FAQ

Q: Does kanata work with any keyboard? A: Yes. It intercepts input at the OS level, so it works with any USB, Bluetooth, or built-in keyboard.

Q: Will it conflict with my keyboard's firmware remapping? A: No. kanata operates on top of whatever the keyboard sends, so firmware and software remapping stack.

Q: Can I use different configs for different keyboards? A: On Linux, you can target specific devices by path. On Windows with the Interception driver, device-specific targeting is also supported.

Q: Is there a GUI? A: kanata is configured via text files. Community-built GUI wrappers exist but the official tool is CLI-based.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产