Keyboard input/Flush the keyboard buffer

From Rosetta Code
Revision as of 14:51, 15 October 2010 by rosettacode>Dkf (→‎Tcl: Added implementation)
Keyboard input/Flush the keyboard buffer is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Flush the keyboard buffer.

BASIC

ZX Spectrum Basic

<lang basic>10 IF INKEY$ <> "" THEN GOTO 10</lang>

PureBasic

<lang PureBasic>While Inkey()<>"": Wend </lang>

Tcl

<lang tcl># No waiting for input fconfigure stdin -blocking 0

  1. Drain the data by not saving it anywhere

read stdin

  1. Flip back into blocking mode (if necessary)

fconfigure stdin -blocking 1</lang>