Summary
I'd like to have some better facilities for dealing with keyboard input, particularly in the context of desktop apps.
Motivation
The existing functions get_keys_down() and get_keys_pressed() hold the building blocks of sophisticated shortcut handling, but it would be nice to have a way to get modifier info alongside the key data, as well as information about repeats. Most of the UI toolkits I've evaluated offer some notion of this by separating out the modifier keys (which are "down" when the shortcut is "pressed") and showing if a keypress is from a repeat or not.
Proposed API
struct Modifiers { shift: bool, alt: bool, ctrl: bool, gui: bool }
struct KeyEvent {
key: KeyCode,
modifiers: Modifiers,
repeat: bool,
pressed: bool, // was it pressed or released?
}
get_key_events() -> Vec<KeyEvent>
I think egui handles this really well overall, in terms of how its Modifiers work, its KeyboardShortcut, and its Key event
Summary
I'd like to have some better facilities for dealing with keyboard input, particularly in the context of desktop apps.
Motivation
The existing functions
get_keys_down()andget_keys_pressed()hold the building blocks of sophisticated shortcut handling, but it would be nice to have a way to get modifier info alongside the key data, as well as information about repeats. Most of the UI toolkits I've evaluated offer some notion of this by separating out the modifier keys (which are "down" when the shortcut is "pressed") and showing if a keypress is from a repeat or not.Proposed API
I think egui handles this really well overall, in terms of how its Modifiers work, its KeyboardShortcut, and its Key event