From 8241b3e3286e727d04dc4d1fd7d1c50b9d45b2cb Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Sat, 31 Aug 2024 10:35:26 +0200 Subject: [PATCH] desktop: Support key codes for non-ASCII characters Flash Player maps non-ASCII input characters to key codes equal to their respective Unicode code points. --- desktop/src/util.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/desktop/src/util.rs b/desktop/src/util.rs index fe51c402fbd6..757e4fcf0810 100644 --- a/desktop/src/util.rs +++ b/desktop/src/util.rs @@ -160,10 +160,6 @@ pub fn winit_to_ruffle_key_code(event: &KeyEvent) -> Option { } fn alpha_to_ruffle_key_code(char: &str) -> Option { - if char.len() != 1 { - return None; - } - let char = char.chars().next()?; if char.is_ascii_alphabetic() { @@ -174,9 +170,9 @@ fn alpha_to_ruffle_key_code(char: &str) -> Option { } if !char.is_ascii() { - // TODO Non-ASCII inputs have codes equal to their Unicode codes and yes, - // they overlap with other codes, so that typing '½' and '-' both produce 189. - return None; + // Non-ASCII inputs have codes equal to their Unicode codes and yes, + // they overlap with other codes, so that typing '½' and '-' both produce 189. + return Some(KeyCode::from_code(char as u32)); } None