diff --git a/kayak_widgets/src/text_box.rs b/kayak_widgets/src/text_box.rs index 0da96fe8645b40924699941a2d1b7de7eee9bae6..5d22a3a27f7d6b0aeec3b34eedbaac0bde6cc5de 100644 --- a/kayak_widgets/src/text_box.rs +++ b/kayak_widgets/src/text_box.rs @@ -63,7 +63,7 @@ pub fn TextBox(value: String, on_change: Option<OnChange>) { if !cloned_has_focus.get().0 { return; } - if c == '\u{8}' { + if is_backspace(c) { if current_value.len() > 0 { current_value.truncate(current_value.len() - 1); } @@ -92,3 +92,10 @@ pub fn TextBox(value: String, on_change: Option<OnChange>) { </Background> } } + +/// Checks if the given character contains the "Backspace" sequence +/// +/// Context: [Wikipedia](https://en.wikipedia.org/wiki/Backspace#Common_use) +fn is_backspace(c: char) -> bool { + c == '\u{8}' || c == '\u{7f}' +} \ No newline at end of file