Expand description
Linux evdev backend for kbd.
This crate provides the low-level Linux input layer that
kbd-global builds on. It handles:
- Device discovery — scan
/dev/input/for keyboards (devices supporting A–Z + Enter) - Hotplug — inotify watch for device add/remove at runtime
- Exclusive grab —
EVIOCGRABfor intercepting events before other applications see them - Event forwarding —
UinputForwarderre-emits unmatched events through a virtual device so they still reach applications in grab mode - Key conversion — extension traits (
EvdevKeyCodeExt,KbdKeyExt) for converting betweenevdev::KeyCodeandkbd::key::Key
§Prerequisites
-
Linux only — this crate uses
/dev/input/,inotify, and/dev/uinput. -
Read access to
/dev/input/— either run as root, or add your user to theinputgroup:sudo usermod -aG input $USER # log out and back in for the group change to take effect -
Write access to
/dev/uinput(only for grab mode) — needed to create the virtual device that forwards unmatched events.
§Architecture
/dev/input/event* DeviceManager
├─ event0 ──┐ ┌─ discover + poll ──→ DeviceKeyEvent
├─ event1 ──┼──────→│ hotplug (inotify) │
└─ event2 ──┘ └───────────────────────┘
│
EvdevKeyCodeExt::to_key()
│
▼
kbd::Key
│
┌─────────────────┼─────────────────┐
│ │ │
Dispatcher KeyState UinputForwarder
(kbd core) (kbd core) (grab mode only)§Usage
Most users should use kbd-global which wraps
this crate in a threaded runtime. Use kbd-evdev directly when you need
low-level control over the poll loop.
§See also
kbd— core key types, matching, and layerskbd-global— threaded runtime built on this crate
Re-exports§
pub use crate::convert::EvdevKeyCodeExt;pub use crate::convert::KbdKeyExt;
Modules§
- convert
- Extension traits for converting between
evdev::KeyCodeandkbd::key::Key. Extension traits for converting between evdev key codes andkbdkey types. - devices
- Device discovery, hotplug monitoring, and event polling. Device discovery, hotplug, and capability detection.
- error
- Error types for the evdev backend. Error types for the evdev backend.
- forwarder
- Virtual uinput device for forwarding and emitting key events. uinput virtual device for event forwarding and emission.