-
-
Notifications
You must be signed in to change notification settings - Fork 135
Description
Problem
The Key enum in three-d only includes alphanumeric keys (A-Z, 0-9), arrow keys, and a handful of special keys (Escape, Tab, Enter, etc.). It's missing all punctuation and symbol keys such as:
Slash(/)Minus(-)Equals(=)Backslash(\)Semicolon(;)Period(.)Comma(,)- Bracket keys, etc.
This means Event::KeyPress is never emitted for these keys, because translate_virtual_key_code() returns None for any VirtualKeyCode that doesn't map to a Key variant.
Additionally, ReceivedCharacter events are suppressed when modifiers.command or modifiers.ctrl is true (in frame_input_generator.rs line ~291), so there is no way at all to detect modifier+symbol key combinations like Cmd+/, Cmd+-, Ctrl+=, etc.
Impact
This makes it impossible to implement common keyboard shortcuts that use punctuation keys:
- Cmd+/ — toggle line comment (standard in virtually every code editor)
- Cmd+- / Cmd+= — zoom out/in
- Cmd+\ — split pane
These are especially important for applications using the egui-gui feature for text editing, since egui's own Key enum includes these keys but three-d never forwards them.
Suggested Fix
- Add the missing variants to the
Keyenum (at minimum:Slash,Minus,Equals,Backslash,Semicolon,Period,Comma,BracketLeft,BracketRight) - Add the corresponding mappings in
translate_virtual_key_code() - (Optional) Also add mappings in the
From<&Key> for egui::Keyimpl so they pass through to egui correctly
This would be a non-breaking addition since it only adds new enum variants.
Workaround
Currently the only workaround is to use a cargo [patch] with a local copy of three-d, or to remap shortcuts to letter keys (e.g. Cmd+Shift+C instead of Cmd+/).
Environment
- three-d 0.18.2
- macOS (also affects Linux/Windows)
- Using
egui-guifeature for a code editor UI