Anonymous user
Keyboard input/Flush the keyboard buffer: Difference between revisions
Keyboard input/Flush the keyboard buffer (view source)
Revision as of 20:18, 8 December 2019
, 4 years ago→{{header|C}}
(added MiniScript example) |
|||
Line 136:
return 0;
}</lang>
{{libheader|Windows}}
<lang c>#include <conio.h>
#include <tchar.h>
void Kbflush(void)
{
while (_kbhit())
{
// The _gettch function reads a single character without echoing it. When reading
// a function key or an arrow key, it must be called twice; the first call returns
// 0x00 or 0xE0 and the second call returns the actual key code. Source: MSDN.
int ch = _gettch();
if (ch == 0x00 || ch == 0xE0)
(void)_gettch();
}
}
int _tmain(void)
{
Kbflush();
return 0;
}</lang>
|