#!python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2017/09/16 20:19:26 +0900> u""" curses sample. キー入力を取得して表示する。 ESCキーかqキーで終了。 Windows10 x64 + Python 2.7.12 32bit + curses 2.2 """ import curses import os def main(win): u"""メイン処理.""" win.nodelay(True) key = "" win.clear() win.addstr("Detected key:") while 1: try: key = win.getkey() win.clear() win.addstr("Detected key:") win.addstr(str(key)) if key == os.linesep or key == "q" or ord(key) == 27: break except Exception as e: # No input pass curses.wrapper(main)