diff --git a/examples/util/print_key_press.cpp b/examples/util/print_key_press.cpp index fa32ee7..e5cd3f9 100644 --- a/examples/util/print_key_press.cpp +++ b/examples/util/print_key_press.cpp @@ -19,7 +19,11 @@ class DrawKey : public Component { for(auto& it : keys[i].input()) code += L" " + std::to_wstring((unsigned int)it); - code = L"(" + code + L" ) -> " + keys[i].character() + L")"; + code = L"(" + code + L" ) -> "; + if (keys[i].is_character()) + code += keys[i].character(); + else + code += L"(special)"; children.push_back(text(code)); } return vbox(std::move(children)); diff --git a/include/ftxui/component/event.hpp b/include/ftxui/component/event.hpp index 69607c5..ec06272 100644 --- a/include/ftxui/component/event.hpp +++ b/include/ftxui/component/event.hpp @@ -49,7 +49,7 @@ struct Event { private: std::string input_; bool is_character_ = false; - wchar_t character_ = '?'; + wchar_t character_ = U'?'; }; } // namespace ftxui diff --git a/src/ftxui/component/event.cpp b/src/ftxui/component/event.cpp index e097dd7..b23ba8e 100644 --- a/src/ftxui/component/event.cpp +++ b/src/ftxui/component/event.cpp @@ -122,6 +122,9 @@ Event Event::GetEvent(std::function getchar) { if (input[0] >= 0 && input[0] < 32) // C0 return Event::Special(input); + if (input[0] == 127) // Delete + return Event::Special(input); + return ParseUTF8(getchar, input); }