C Language Development Kit/Functions/ResetKey
From OptiWiki
| Description | This function clears the keyboard buffer. |
| Syntax | void resetkey(void); |
| Arguments | None |
| Returns | None |
| Remarks | This function is useful when one wants to wait for a key press. Call this function
to avoid that a previous keystroke, still in the keyboard buffer, causes e.g. kbhit() to return with TRUE. |
| Example | #include "lib.h" #include <stdio.h> void main( void ) { int x, y; while( 1 ) { printf("\f"); for( x=0; x < 96; x++) drawline( x, 0, 50, 24, 1); for( y=0; y < 48; y++) drawline( 96, y, 50, 24, 1); for( x=96; x >= 0; x\-\-) drawline( x, 47, 50, 24, 1); for( y=47; y >= 0; y\-\-) drawline( 0, y, 50, 24, 1); gotoxy( 3, 2); printf("Press key"); resetkey(); while(!kbhit()) idle(); } } |
