Fix F10 and Alt+F handling on Windows (#24745)

GiM created

Closes #24744
and should also fix #17819 

The change is split into two commits, first one adds F10 handling (it
needs to be handled inside `parse_syskeydown_msg_keystroke`, the second
one properly handles `Alt+Fn` combinations, this also needs to happen in
`parse_syskeydown_msg_keystroke` and is similar to a fragment inside
`parse_keydown_msg_keystroke`

Release Notes:

- Fixes F10 and Alt+Fn handling on windows

Change summary

crates/gpui/src/platform/windows/events.rs | 37 ++++++++++++++++++++---
1 file changed, 31 insertions(+), 6 deletions(-)

Detailed changes

crates/gpui/src/platform/windows/events.rs 🔗

@@ -1201,14 +1201,23 @@ fn handle_system_theme_changed(
 
 fn parse_syskeydown_msg_keystroke(wparam: WPARAM) -> Option<Keystroke> {
     let modifiers = current_modifiers();
+    let vk_code = wparam.loword();
+
+    // on Windows, F10 can trigger this event, not just the alt key,
+    // so when F10 was pressed, handle only it
     if !modifiers.alt {
-        // on Windows, F10 can trigger this event, not just the alt key
-        // and we just don't care about F10
-        return None;
+        if vk_code == VK_F10.0 {
+            let offset = vk_code - VK_F1.0;
+            return Some(Keystroke {
+                modifiers,
+                key: format!("f{}", offset + 1),
+                key_char: None,
+            });
+        } else {
+            return None;
+        }
     }
 
-    let vk_code = wparam.loword();
-
     let key = match VIRTUAL_KEY(vk_code) {
         VK_BACK => "backspace",
         VK_RETURN => "enter",
@@ -1226,7 +1235,23 @@ fn parse_syskeydown_msg_keystroke(wparam: WPARAM) -> Option<Keystroke> {
         VK_ESCAPE => "escape",
         VK_INSERT => "insert",
         VK_DELETE => "delete",
-        _ => return basic_vkcode_to_string(vk_code, modifiers),
+        _ => {
+            let basic_key = basic_vkcode_to_string(vk_code, modifiers);
+            if basic_key.is_some() {
+                return basic_key;
+            } else {
+                if vk_code >= VK_F1.0 && vk_code <= VK_F24.0 {
+                    let offset = vk_code - VK_F1.0;
+                    return Some(Keystroke {
+                        modifiers,
+                        key: format!("f{}", offset + 1),
+                        key_char: None,
+                    });
+                } else {
+                    return None;
+                }
+            }
+        }
     }
     .to_owned();