diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 1c47d7eb..e541273f 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -729,7 +729,7 @@ impl State { // When telling users "Press Ctrl-F to find", this is where we should // look for the "F" key, because they may have a dvorak layout on // a qwerty keyboard, and so the logical "F" character may not be located on the physical `KeyCode::KeyF` position. - logical_key, + logical_key: winit_logical_key, text, @@ -748,7 +748,7 @@ impl State { None }; - let logical_key = key_from_winit_key(logical_key); + let logical_key = key_from_winit_key(winit_logical_key); // Helpful logging to enable when adding new key support log::trace!( @@ -791,7 +791,11 @@ impl State { }); } - if let Some(text) = &text { + if let Some(text) = text + .as_ref() + .map(|t| t.as_str()) + .or_else(|| winit_logical_key.to_text()) + { // Make sure there is text, and that it is not control characters // (e.g. delete is sent as "\u{f728}" on macOS). if !text.is_empty() && text.chars().all(is_printable_char) { @@ -805,7 +809,7 @@ impl State { if pressed && !is_cmd { self.egui_input .events - .push(egui::Event::Text(text.to_string())); + .push(egui::Event::Text(text.to_owned())); } } }