Keyboard input/Flush the keyboard buffer: Difference between revisions
Content added Content deleted
(added MiniScript example) |
|||
Line 136: | Line 136: | ||
return 0; |
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> |
}</lang> |
||