mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2024-11-14 17:40:24 -08:00
31 lines
590 B
Python
31 lines
590 B
Python
"""
|
|
This module currently provides a cross-platform getch function
|
|
"""
|
|
|
|
try:
|
|
# Windows
|
|
from msvcrt import getch # type: ignore
|
|
|
|
getch # workaround for https://github.com/kevinw/pyflakes/issues/13
|
|
except ImportError:
|
|
pass
|
|
|
|
try:
|
|
# Unix
|
|
import sys
|
|
import tty
|
|
import termios
|
|
|
|
def getch(): # type: ignore
|
|
fd = sys.stdin.fileno()
|
|
old = termios.tcgetattr(fd)
|
|
try:
|
|
tty.setraw(fd)
|
|
return sys.stdin.read(1)
|
|
finally:
|
|
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
|
|
|
|
|
except ImportError:
|
|
pass
|