Ignore text in KeyPressed with private use chars

Apparently, macOS likes to use these for simple keys.
This commit is contained in:
Héctor Ramón Jiménez 2024-02-26 05:57:10 +01:00
parent f67db901ff
commit a9733e9906
No known key found for this signature in database
GPG key ID: 0BF4EC06CD8E5686

View file

@ -224,7 +224,7 @@ pub fn window_event(
// TODO: Fix inconsistent API on Wasm
event.text
}
};
}.filter(|text| !text.as_str().chars().any(is_private_use));
let winit::event::KeyEvent {
state, location, ..
@ -839,3 +839,8 @@ pub fn icon(icon: window::Icon) -> Option<winit::window::Icon> {
winit::window::Icon::from_rgba(pixels, size.width, size.height).ok()
}
// See: https://en.wikipedia.org/wiki/Private_Use_Areas
fn is_private_use(c: char) -> bool {
c >= '\u{E000}' && c <= '\u{F8FF}'
}