try out unicode if key_down fail

This commit is contained in:
rustdesk
2022-05-09 01:36:56 +08:00
parent b526bf4a67
commit 2724bd4000
3 changed files with 26 additions and 7 deletions

View File

@@ -354,9 +354,13 @@ impl KeyboardControllable for Enigo {
}
fn key_down(&mut self, key: Key) -> crate::ResultType {
let code = self.key_to_keycode(key);
if code == 0 {
return Err("".into());
}
if let Some(src) = self.event_source.as_ref() {
if let Ok(event) =
CGEvent::new_keyboard_event(src.clone(), self.key_to_keycode(key), true)
CGEvent::new_keyboard_event(src.clone(), code, true)
{
self.post(event);
}

View File

@@ -195,7 +195,11 @@ impl KeyboardControllable for Enigo {
}
fn key_down(&mut self, key: Key) -> crate::ResultType {
let res = keybd_event(0, self.key_to_keycode(key), 0);
let code = self.key_to_keycode(key);
if code == 0 || code == 65535 {
return Err("".into());
}
let res = keybd_event(0, code, 0);
if res == 0 {
let err = get_error();
if !err.is_empty() {