int getkeys()
{
goback:
DWORD begtime=GetTickCount();
DWORD endtime=GetTickCount();
while(begtime+10>endtime) \\ Stops the program for 10 ms preventing stack overflow.
{endtime=GetTickCount();}
long up=GetKeyState(VK_UP);
if(up>0)
{return 1;}
long left=GetKeyState(VK_LEFT);
if(left>0)
{return 2;}
long down=GetKeyState(VK_DOWN);
if(down>0)
{return 3;}
long right=GetKeyState(VK_RIGHT);
if(right>0)
{return 4;}
goto goback; \\ If all other options fail(no key presses) it restarts the funtion.
}
It is meant to get the key currently down or stop the program until there is a key down, but if I call it again and there is no key down, it will give me the same key it did before. Please help me find a better way to do this. Thanks.