Platform-aware keyboard key name handling for Rust applications. This crate is roughly a fork of keyboard-keynames, with a few extra features as well as integration with the keycode crate and winit::event::VirtualKeyCode
(requires winit
feature).
Features:
- Generates user-friendly strings for modifier keys that respect platform conventions
- Generates user-friendly strings for keys based on scancode and current keyboard layout
- Supports Windows, Linux (X11 and Wayland), and macOS
Note that on macOS there does not appear to be an API for getting key names from scancodes, so there is instead a hard-coded table based on the US QWERTY layout. This isn't ideal, but at least it's something.
Run cargo run --example all_keys
to see the key names produced by this library.
OS | Modifier names and order |
---|---|
Windows | Ctrl + Shift + Alt + Win + ... |
Linux | Ctrl + Shift + Alt + Super + ... |
macOS | Ctrl + Option + Shift + Cmd + ... |
WASM support is highly desirable. PRs welcome!