int a;
While (1)
{
A=_kbhit ();
If (a!=0)
{
Printf (" 1 ");
}
}
After pressing the keyboard _kbhit content will always perform under (), what's the testing loosen the function of the keyboard? After loosening the keyboard is reset the value of a
CodePudding user response:
int a;
While (1)
{
A=_kbhit ();
If (a!=0)
{
Printf (" 1 ");
}
The else
Printf (" 0 ");
}
Loosen the consequences of not can see?
CodePudding user response:
Like this after the release has been output 1, a value is not reset, I want to loosen or 0 after the keyboardCodePudding user response:
int a;
While (1)
{
A=_kbhit ();
If (a!=0)
{
Printf (" 1 ");
_getch ();
}
The else
Printf (" 0 ");
}
Add a _getch (), implementation is realized, but I am doing the movement of the characters, I am using GetKeyState mobile module, but add _getch (), hold down the keyboard characters will move first, card, and then has been moving, try _getch () into rewind (stdin) or the fflush (stdin) to remove the keyboard buffer, but have no effect, there are other methods to remove the keyboard buffer
CodePudding user response:
You are GetKeyState, even _getch stem what? Don't understand,In addition whether GetKeyState or _getch will not deal with stdin, so you deal with stdin doesn't work,
CodePudding user response:
Want to use _getch () to remove the keyboard buffer, like this _kbhitd value is reset to zero, I use GetKeyState, under the _kbhit statements will be executed repeatedly,My purpose is to achieve a stationary time put a set of animations, move put another set of animation, _kbhit does not reset when static play mobile animation, now don't use _kbhit in a way of thinking is to solve the problem, if you would learn loose key detection better