h2o-py/h2o/demos.py
def _wait_for_keypress():
    """
    Wait for a key press on the console and return it.

    Borrowed from http://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key
    """
    result = None
    if os.name == "nt":
        # noinspection PyUnresolvedReferences
        import msvcrt
        result = msvcrt.getch()
    else:
        import termios
        fd = sys.stdin.fileno()

        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)

        try:
            result = sys.stdin.read(1)
        except IOError:
            pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)

    return result
def _wait_for_keypress():
    result = None
    if os.name == "nt":
        # noinspection PyUnresolvedReferences
        import msvcrt
        result = msvcrt.getch()
    else:
        import termios
        fd = sys.stdin.fileno()

        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)

        try:
            result = sys.stdin.read(1)
        except IOError:
            pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)

    return result
def _wait_for_keypress ( ) : result = None if os . name == "nt" : # noinspection PyUnresolvedReferences import msvcrt result = msvcrt . getch ( ) else : import termios fd = sys . stdin . fileno ( ) oldterm = termios . tcgetattr ( fd ) newattr = termios . tcgetattr ( fd ) newattr [ 3 ] = newattr [ 3 ] & ~ termios . ICANON & ~ termios . ECHO termios . tcsetattr ( fd , termios . TCSANOW , newattr ) try : result = sys . stdin . read ( 1 ) except IOError : pass finally : termios . tcsetattr ( fd , termios . TCSAFLUSH , oldterm ) return result
Wait for a key press on the console and return it.

    Borrowed from http://stackoverflow.com/questions/983354/how-do-i-make-python-to-wait-for-a-pressed-key
Wait for a key press on the console and return it .