I\'m coding a program that reads data directly from user input and was wondering how could I read all data until ESC button on keyboard is pressed. I found only something li
After you read the line, go though all characters you just read and look for the escape ASCII value (decimal 27).
Here's what I mean:
while (std::getline(std::cin, line) && moveOn)
{
std::cout << line << "\n";
// Do whatever processing you need
// Check for ESC
bool got_esc = false;
for (const auto c : line)
{
if (c == 27)
{
got_esc = true;
break;
}
}
if (got_esc)
break;
}