kbd-evdev
Low-level Linux input backend for the kbd workspace.
Most applications should start with kbd-global, which wraps this crate in a threaded runtime. Use kbd-evdev directly when you need to own the poll loop yourself — your own event loop, your own threading, your own timing.
Requirements
- Linux only
- Read access to
/dev/input/ - Write access to
/dev/uinputif you use grab mode and forwarding
To read input devices without running as root, add your user to the input group:
Log out and back in for the group change to take effect.
What it handles
- Device discovery — scans
/dev/input/for keyboards (devices that support A–Z + Enter) - Hotplug — inotify watch picks up devices added or removed at runtime
- Exclusive grab —
EVIOCGRABintercepts events before other applications see them - Event forwarding — a uinput virtual device re-emits unmatched events in grab mode so other apps still work
- Key conversion — extension traits for
evdev::KeyCode↔kbd::key::Key
Example
Convert between evdev and kbd key types:
use KeyCode;
use Key;
use ;
let key: Key = KEY_A.to_key;
assert_eq!;
let code: KeyCode = A.to_key_code;
assert_eq!;
Discover and poll devices:
use Path;
use ;
let manager = new;
let _poll_fds = manager.poll_fds;
Call poll(2) on DeviceManager::poll_fds(), then pass the ready descriptors to DeviceManager::process_polled_events() — you get back key events (with device identity and press/release state) and disconnection notifications.
Related crates
kbd— the core matching engine that processes the key events this crate produceskbd-global— threaded runtime built on top of this crate, handles the event loop for you
License
kbd-evdev is licensed under the MIT license. See the LICENSE file for more information.