Crate key_names

Source
Expand description

Platform-aware keyboard key name handling for Rust applications.

Structs§

KeyMap
Ergonomic access to a specific key’s mapping of values
KeyModifiers
Bitmask for key modifiers based on the USB HID standard
KeyboardState
Keyboard state that helps manage pressed keys, rollover, and generating USB HID reports

Enums§

KeyMapping
The mapping of values between platforms for a specific key
KeyMappingCode
W3 browser event code for a specific key
KeyMappingId
Id for a specific key
KeyState
State of any key, whether it is pressed or not

Constants§

ALT_STR
OS’s conventional name for the Alt modifier.
CTRL_STR
OS’s conventional name for the Ctrl modifier.
LOGO_STR
OS’s conventional name for the logo modifier.
MODIFIERS_ORDER
OS’s conventional modifiers order, represented as an ASCII string containing the characters csam for CTRL, SHIFT, ALT, and META/LOGO respectively in some order.
NUM_KEYS
Max keys is 235, but this is the size of array used to manage state
SHIFT_STR
OS’s conventional name for the Shift modifier.

Functions§

key_name
Uses the operating system’s API to return a name for the key.
key_to_sc
Converts the OS-independent key mapping code back into an OS-specific scancode. This is not guaranteed to produce the original scancode.
mods_prefix_string
Returns a string representing modifiers using the OS’s conventional names and ordering. For example, on Windows this function might produce “Ctrl + Shift + Alt + Win + “ while on macOS it might produce “Ctrl + Option + Shift
sc_to_key
Converts the OS-specific scancode to an OS-independent key mapping code.
scancode_name
Uses the operarting system’s API to return a name for the scancode.