https://github.com/hactarce/key-names
Platform-aware keyboard key name handling for Rust applications
https://github.com/hactarce/key-names
cross-platform crossplatform keybind keybinding keybindings keyboard keyboard-events keyboard-layout keyboard-shortcuts linux macos osx rust scan-code scan-codes scancode scancodes windows winit
Last synced: 14 days ago
JSON representation
Platform-aware keyboard key name handling for Rust applications
- Host: GitHub
- URL: https://github.com/hactarce/key-names
- Owner: HactarCE
- License: apache-2.0
- Created: 2021-12-20T22:25:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T18:29:40.000Z (2 months ago)
- Last Synced: 2025-05-06T20:43:23.555Z (23 days ago)
- Topics: cross-platform, crossplatform, keybind, keybinding, keybindings, keyboard, keyboard-events, keyboard-layout, keyboard-shortcuts, linux, macos, osx, rust, scan-code, scan-codes, scancode, scancodes, windows, winit
- Language: Rust
- Homepage:
- Size: 91.8 KB
- Stars: 6
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# key-names
[](https://crates.io/crates/key-names)
[](https://docs.rs/key-names)Platform-aware keyboard key names for Rust applications. This crate is a fork of [keyboard-keynames](https://crates.io/crates/keyboard-keynames) that adds a few extra features including [winit](https://crates.io/crates/winit) integration.
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), macOS, and webThis crate currently queries the keyboard layout only on Windows and Linux (X11 and Wayland). On macOS and web, there is instead a hard-coded table based on the US QWERTY layout. I would love a PR that adds support for querying the layout on either of these.
Run `cargo run --example all_keys` to see the key names produced by this library.
## Modifier names and order
| Platform | Modifier names and order |
| -------- | --------------------------------- |
| Windows | Ctrl + Shift + Alt + Win + ... |
| Linux | Ctrl + Shift + Alt + Super + ... |
| macOS | Ctrl + Option + Shift + Cmd + ... |
| Web | Ctrl + Shift + Alt + Super + ... |## Contributing
Bugfix PRs welcome! Before investing time & effort into a new feature, it might be good to open an issue to discuss. I made this crate initially for the needs of [Hyperspeedcube](https://github.com/HactarCE/Hyperspeedcube), and I'm open to adding more features if people would find it useful and it's possible to support cross-platform.