on-internet
← Community

A way to distinguish `\e` from escaped keys like `\e[A` in C++

Stack Overflow ·

I'm writing a readline replacement in C++, and I want to process terminal input in raw mode, including special/escaped keys like "up arrow" \e[A. However, I also want to be able to distinguish between a single press of the escape key \e followed by a press of [ and a press of A vs a press of the up arrow. I assume that the primary difference between those two situations is that when up arrow is pressed, the input characters come in within less than a millisecond, so I thought I could do something like: #include <termios.h> #include <absl/strings/escaping.h> #include <iostream> termios enter_ra

Comments

Sign in or sign up to comment and upvote.

No comments yet.