diff --git a/terminal/TerminalWidget.cpp b/terminal/TerminalWidget.cpp index 792938bb..a55274f9 100644 --- a/terminal/TerminalWidget.cpp +++ b/terminal/TerminalWidget.cpp @@ -88,7 +88,11 @@ Result TerminalWidget::init(char* const* args) Result TerminalWidget::handle_key_event(const ui::KeyEventRequest& request) { + // Avoid handling "key released" events if (!request.pressed) return ui::EventResult::DidNotHandle; + // Non-printable key or key that has no special character (unlike Tab or Enter). We exit early to avoid inserting an + // invalid zero byte into the terminal input (this would also happen on Shift or Ctrl keypresses). + if (request.letter == '\0') return ui::EventResult::DidNotHandle; query_termios();