Keyboard library for C++

Viewed 13

I'm making a program, whatever I need a function or a library that returns me a boolean value about a key pressed like this:

#include <iostream>
#include <string>

bool keyPressed(std::string key) {
   // Function;
}

int main() {
   std::cout << "Press spacebar to exit of loop...\n";
   while (true) {
      // the "keyPressed" is fictional
      if (keyPressed("spacebar")) break;
      else {
         // Do something else;
      }
   }
}

I do not want the program to stop until you press a key, as getch() does

P. S. I'm creating a Terminal program.

0 Answers
Related