Hello.
I am making a game where it detects if a key is pressed or not, and i am using kbhit(). But once a key is pressed, kbhit always returns 1, even if there is no key pressed. What am I doing wrong? Thanks.
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
int i;
while(true)
{
i=kbhit();
if(i==1)
{
cout<<"You pressed a key.";
}
Sleep(0.5*1000);
}
return 0;
}