RosettaCodeData/Task/Keyboard-input-Flush-the-ke.../Python/keyboard-input-flush-the-ke...

9 lines
213 B
Python

def flush_input():
try:
import msvcrt
while msvcrt.kbhit():
msvcrt.getch()
except ImportError:
import sys, termios
termios.tcflush(sys.stdin, termios.TCIOFLUSH)