GetAsyncKeyState(VK_ESCAPE) can be used with windows.h but in linux how this can be used.
please don't mention std::cin.get() or getch()
because it waits for user to input a ch but GetAsyncKeyState(VK_ESCAPE) works continually.
any alternative of GetAsyncKeyState(VK_ESCAPE) in LINUX ?
#include <windows.h> //works in win but doesnt in linux
#include <iostream>
void Esc();
void Start();
void Esc()
{
//std::cout<<"press esc to exit! \n";
if (GetAsyncKeyState(VK_ESCAPE)) // how to use such thing in linux?
{
return;
}
else
Start();
}
void Start()
{
std::cout<< "hello again \n";
// i want to keep seeing this msg "hello again"
//again and again without pressing any key just ESC to terminate
Sleep (1000);
Esc();
return;
}
int main()
{
std::cout<< "starting... press esc to exit!\n";
Sleep (1000); //in linux we use sleep or usleep. in win s is capital
Start();
Esc();
std::cout<<"exited: \n";
Sleep (1000);
return 0;
}