fix(editor): exclude Alt-modified keys from web tool switch

Codex review of the tool-switch wiring flagged that the keydown is_mod gate
covers Cmd/Ctrl but not Alt, so an Alt+letter could trip the bare-letter tool
router. Gate the tool shortcut on !alt_key; a resulting printable char still
types via apply_text.
This commit is contained in:
Kayshen-X 2026-06-19 09:53:06 +08:00
parent 5f3d511876
commit 3a70bc6f13

View file

@ -1147,7 +1147,11 @@ pub async fn mount_ck(canvas_id: String) -> Result<(), JsValue> {
// (and any keystroke while a field is focused) types via
// apply_text.
if !is_mod {
if b.host.apply_tool_shortcut(key.as_str()) {
// Alt-modified keys never switch tools — Alt is a chord
// modifier (and on macOS yields special glyphs like ®/π),
// so an Alt+letter must not trip the bare-letter router.
// A resulting printable char still types via apply_text.
if !evt.alt_key() && b.host.apply_tool_shortcut(key.as_str()) {
consumed = true;
} else {
let mut chars = key.chars();