Support extended keys on Mac (F20-F35) (#26899)

Closes #4640

About the support limit of Fn:

Mac F1-F35
Win F1-F24
Linux F1-F35
Terminal F1-F20

Release Notes:

- Improved support for extended keyboards on Mac (F20-F35)
This commit is contained in:
0x2CA 2025-03-17 18:56:46 +08:00 committed by GitHub
parent 210d8d5530
commit bf735da3f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 0 deletions

View file

@ -252,6 +252,22 @@ fn is_printable_key(key: &str) -> bool {
| "f17"
| "f18"
| "f19"
| "f20"
| "f21"
| "f22"
| "f23"
| "f24"
| "f25"
| "f26"
| "f27"
| "f28"
| "f29"
| "f30"
| "f31"
| "f32"
| "f33"
| "f34"
| "f35"
| "backspace"
| "delete"
| "left"

View file

@ -58,6 +58,22 @@ pub fn key_to_native(key: &str) -> Cow<str> {
"f17" => NSF17FunctionKey,
"f18" => NSF18FunctionKey,
"f19" => NSF19FunctionKey,
"f20" => NSF20FunctionKey,
"f21" => NSF21FunctionKey,
"f22" => NSF22FunctionKey,
"f23" => NSF23FunctionKey,
"f24" => NSF24FunctionKey,
"f25" => NSF25FunctionKey,
"f26" => NSF26FunctionKey,
"f27" => NSF27FunctionKey,
"f28" => NSF28FunctionKey,
"f29" => NSF29FunctionKey,
"f30" => NSF30FunctionKey,
"f31" => NSF31FunctionKey,
"f32" => NSF32FunctionKey,
"f33" => NSF33FunctionKey,
"f34" => NSF34FunctionKey,
"f35" => NSF35FunctionKey,
_ => return Cow::Borrowed(key),
};
Cow::Owned(String::from_utf16(&[code]).unwrap())
@ -332,6 +348,22 @@ unsafe fn parse_keystroke(native_event: id) -> Keystroke {
Some(NSF17FunctionKey) => "f17".to_string(),
Some(NSF18FunctionKey) => "f18".to_string(),
Some(NSF19FunctionKey) => "f19".to_string(),
Some(NSF20FunctionKey) => "f20".to_string(),
Some(NSF21FunctionKey) => "f21".to_string(),
Some(NSF22FunctionKey) => "f22".to_string(),
Some(NSF23FunctionKey) => "f23".to_string(),
Some(NSF24FunctionKey) => "f24".to_string(),
Some(NSF25FunctionKey) => "f25".to_string(),
Some(NSF26FunctionKey) => "f26".to_string(),
Some(NSF27FunctionKey) => "f27".to_string(),
Some(NSF28FunctionKey) => "f28".to_string(),
Some(NSF29FunctionKey) => "f29".to_string(),
Some(NSF30FunctionKey) => "f30".to_string(),
Some(NSF31FunctionKey) => "f31".to_string(),
Some(NSF32FunctionKey) => "f32".to_string(),
Some(NSF33FunctionKey) => "f33".to_string(),
Some(NSF34FunctionKey) => "f34".to_string(),
Some(NSF35FunctionKey) => "f35".to_string(),
_ => {
// Cases to test when modifying this:
//