Anonymous user
Keyboard input/Keypress check: Difference between revisions
m
→{{header|Python}}
m (added whitespace before the TOC (table of contents), added other whitespace to the task's preamble.) |
|||
Line 366:
<lang python>#!/usr/bin/env python
import sys
if sys.version_info.major < 3:
▲import thread
import thread as _thread
else:
import _thread
import time
Line 376 ⟶ 379:
except ImportError:
def getch(): # define non-Windows version
import
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
Line 392 ⟶ 395:
char = getch()
while True:
if char is not None:
print
break
print
time.sleep(5)</lang>
|