Does anyone have a snippet of code that doesn't use windows.h
to check for a key press within a while loop. Basically this code but without having to use windows.h
to do it. I want to use it on Linux and Windows.
#include <windows.h>
#include <iostream>
int main()
{
bool exit = false;
while(exit == false)
{
if (GetAsyncKeyState(VK_ESCAPE))
{
exit = true;
}
std::cout<<"press esc to exit! "<<std::endl;
}
std::cout<<"exited: "<<std::endl;
return 0;
}
s/GetAsyncKeyState(VK_ESCAPE)/GetAsyncKeyState(VK_ESCAPE) & 0x8000
. – Romanticismcin.get()
kind of works, but I'm very iffy with doing that. – Romanticism