Skip to main content

Crate wkb

Crate wkb 

Source
Expand description

§wkb — Wayland Keyboard

A lightweight, pure Rust keyboard handling library for Wayland. WKB compiles XKB keymaps, tracks modifier and compose state, and maps evdev key codes to characters — all without C dependencies.

§Quick Start

use wkb::{WKB, KeyDirection};

// Build from an XKB keymap string (e.g. received from a Wayland compositor)
let keymap_string = std::fs::read_to_string("/path/to/keymap").unwrap();
let mut wkb = WKB::new_from_string(keymap_string);

// Process a key press (evdev code 38 = 'a' on US layout)
let (ch, is_modifier) = wkb.key(38, KeyDirection::Down);

§Feature Flags

  • xkb (default) — XKB keymap compilation via the xkb-core crate.
  • compose (default) — Compose-key / dead-key sequence support.
  • testing — Exposes internal helpers for integration tests. Not part of the public API.

Structs§

WKB
Core keyboard state machine. Tracks modifier state, key presses, and compose sequences.

Enums§

KeyDirection