Bevy version and features
0.19.0, default features (also affects current main).
[Optional] Relevant system information
Windows 10 / Linux — reproducible on any OS. Not rendering-related.
Reproducible with any non-Latin keyboard layout (Arabic, Ukrainian, Russian, Greek,
Hebrew, etc.).
What you did
- Run the
text_input example (or any app using the TextInput /
EditableText widget from bevy_ui_widgets).
- Switch the OS keyboard layout to a non-Latin one (e.g. Ukrainian).
- Type some text, then press
Ctrl+A (Cmd+A on macOS), Ctrl+C,
Ctrl+X, Ctrl+V.
What went wrong
- Expected: standard editing shortcuts (Select All / Copy / Cut / Paste)
work regardless of the active keyboard layout, as they do in native
text fields and browsers.
- Actual: none of these shortcuts work while a non-Latin layout is active.
Switching back to a US/Latin layout makes them work again.
Additional information
The cause is in bevy_ui_widgets/src/text_input.rs,
on_focused_keyboard_input: the shortcuts are matched against the
logical key:
(COMMAND, Key::Character(c)) if c.eq_ignore_ascii_case("a") => {
queue_edit(TextEdit::SelectAll);
}
With a Russian layout, Ctrl+A arrives as Key::Character("ф"),
Ctrl+C as "с" (Cyrillic), etc., so the guards never match. The
layout-independent Named keys (arrows, Home/End, Backspace, Shift+Delete)
work fine.
The winit docs for KeyEvent::logical_key explicitly warn against using
it for keyboard shortcuts for exactly this reason:
https://docs.rs/winit/latest/winit/event/struct.KeyEvent.html
Possible fixes:
- Match these four shortcuts on the physical
key_code
(KeyCode::KeyA/KeyC/KeyX/KeyV) when a COMMAND modifier is held.
Caveat: on Latin non-QWERTY layouts (e.g. AZERTY) the physical position
differs from the key label, so pure physical matching relocates the
shortcuts there.
- Hybrid approach (what most toolkits/browsers do): match
logical_key
first, and fall back to the physical key_code when the logical key is
not an ASCII character. This keeps AZERTY/QWERTZ conventions intact and
fixes non-Latin layouts.
- Longer term: expose winit's
key_without_modifiers /
layout-aware key data in bevy_input.
Bevy version and features
0.19.0, default features (also affects current
main).[Optional] Relevant system information
Windows 10 / Linux — reproducible on any OS. Not rendering-related.
Reproducible with any non-Latin keyboard layout (Arabic, Ukrainian, Russian, Greek,
Hebrew, etc.).
What you did
text_inputexample (or any app using theTextInput/EditableTextwidget frombevy_ui_widgets).Ctrl+A(Cmd+Aon macOS),Ctrl+C,Ctrl+X,Ctrl+V.What went wrong
work regardless of the active keyboard layout, as they do in native
text fields and browsers.
Switching back to a US/Latin layout makes them work again.
Additional information
The cause is in
bevy_ui_widgets/src/text_input.rs,on_focused_keyboard_input: the shortcuts are matched against thelogical key:
With a Russian layout,
Ctrl+Aarrives asKey::Character("ф"),Ctrl+Cas"с"(Cyrillic), etc., so the guards never match. Thelayout-independent
Namedkeys (arrows, Home/End, Backspace, Shift+Delete)work fine.
The winit docs for
KeyEvent::logical_keyexplicitly warn against usingit for keyboard shortcuts for exactly this reason:
https://docs.rs/winit/latest/winit/event/struct.KeyEvent.html
Possible fixes:
key_code(
KeyCode::KeyA/KeyC/KeyX/KeyV) when aCOMMANDmodifier is held.Caveat: on Latin non-QWERTY layouts (e.g. AZERTY) the physical position
differs from the key label, so pure physical matching relocates the
shortcuts there.
logical_keyfirst, and fall back to the physical
key_codewhen the logical key isnot an ASCII character. This keeps AZERTY/QWERTZ conventions intact and
fixes non-Latin layouts.
key_without_modifiers/layout-aware key data in
bevy_input.