Skip to content

Commit 82f2eb3

Browse files
committed
chore: handle space bar as key event
1 parent b80d143 commit 82f2eb3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/utils.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,22 @@ pub fn key_event_to_string(event: KeyEvent) -> String {
345345
match event.code {
346346
KeyCode::Char(c) => {
347347
if event.modifiers == KeyModifiers::CONTROL {
348-
// Sonderfall: Nur Control -> Großbuchstabe
348+
// Special case for Control + Char -> "Ctrl + UPPERCASE_CHAR"
349349
format!("Ctrl + {}", c.to_ascii_uppercase())
350350
} else if event.modifiers == KeyModifiers::SHIFT {
351-
// Shift + Char -> Nur Char (Groß-/Sonderzeichen bereits berücksichtigt)
351+
// Shift + Char -> Only the char (because Shift is usually handled by the char itself, e.g. 'a' with Shift becomes 'A')
352352
c.to_string()
353353
} else if event.modifiers != KeyModifiers::NONE {
354-
// Andere Modifier -> Modifier + Char
354+
// Other Modifier -> Modifier + Char
355355
format!("{} + {}", modifiers_str, c)
356356
} else {
357-
// Kein Modifier -> Nur Char
358-
c.to_string()
357+
// No modifier -> Just the char
358+
// handle case Space char
359+
if c == ' ' {
360+
"Space".to_string()
361+
} else {
362+
c.to_string()
363+
}
359364
}
360365
}
361366
KeyCode::Left => format_arrow_key("Left Arrow", &modifiers_str),

0 commit comments

Comments
 (0)