示例#1
0
def mainloop(keyfunc=None):
    change_termios()
    while True:
        while not kbhit(): continue
        key = getch()
        if isinstance(key, bytes) and bytes != str: key = key.decode()
        if key not in ascii_to_keycode: continue
        keycode = ascii_to_keycode[key]
        if keycode == "ESCAPE": break
        if keyfunc is not None: keyfunc(keycode)
    restore_termios()
示例#2
0
def mainloop(keyfunc=None):
    change_termios()
    while True:
        while not kbhit():
            continue
        key = getch()
        if isinstance(key, bytes) and bytes != str: key = key.decode()
        if key not in ascii_to_keycode: continue
        keycode = ascii_to_keycode[key]
        if keycode == "ESCAPE": break
        if keyfunc is not None: keyfunc(keycode)
    restore_termios()
示例#3
0
import getch

while True:
    if getch.kbhit():
        key = ord(getch.getch())

        print(key)

        if key == 27:
            break