How do I detect if a key is being held down in C++? An example of how I'd like to use it:
while (varOne == 0) {
if ('A' Key Pressing Code Detection Magic Goes Here) {
std::cout << "The 'A' key has been pressed.";
varOne = 2;
}
}
I have found a few articles saying to use the conio.h
library, however a bunch of people advise against using it. Should I use conio.h
? Or is there some other method? (Not sure if it matters, but I'm using VS Code on Linux.)