[Documentation] [TitleIndex] [WordIndex

import termios, tty, sys, select

def getKey():
    settings = termios.tcgetattr(sys.stdin)
    try:
        tty.setraw(sys.stdin.fileno())
        select.select([sys.stdin], [], [], 0)
        key = sys.stdin.read(1)
        return key
    finally:
        termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)

2024-12-28 13:08