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

9 lines
213 B
Python
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
def flush_input():
try:
import msvcrt
while msvcrt.kbhit():
msvcrt.getch()
except ImportError:
import sys, termios
termios.tcflush(sys.stdin, termios.TCIOFLUSH)