Fix ALT + numbers and ignore invalid keys (#488)
This commit is contained in:
parent
729f3c6931
commit
2857b30f24
@ -79,19 +79,16 @@ fn parse_key_event_record(key_event: &KeyEventRecord) -> Option<KeyEvent> {
|
||||
let character_raw = key_event.u_char;
|
||||
|
||||
if character_raw < 255 {
|
||||
let mut character = character_raw as u8 as char;
|
||||
|
||||
if modifiers.contains(KeyModifiers::ALT) {
|
||||
// If the ALT key is held down, pressing the A key produces ALT+A, which the system does not treat as a character at all, but rather as a system command.
|
||||
// The pressed command is stored in `virtual_key_code`.
|
||||
let command = key_event.virtual_key_code as u8 as char;
|
||||
|
||||
if command.is_alphabetic() {
|
||||
character = command;
|
||||
} else {
|
||||
// Invalid character
|
||||
if character_raw == 0 {
|
||||
return None;
|
||||
}
|
||||
} else if modifiers.contains(KeyModifiers::CONTROL) {
|
||||
|
||||
let mut character = character_raw as u8 as char;
|
||||
|
||||
if modifiers.contains(KeyModifiers::CONTROL)
|
||||
&& !modifiers.contains(KeyModifiers::ALT)
|
||||
{
|
||||
// we need to do some parsing
|
||||
character = match character_raw as u8 {
|
||||
c @ b'\x01'..=b'\x1A' => (c as u8 - 0x1 + b'a') as char,
|
||||
|
Loading…
Reference in New Issue
Block a user