Name

getch

Synopsis

                           w.getch( )

Returns an integer c corresponding to a user keystroke. c between 0 and 255 represents an ordinary character, while c greater than 255 represents a special key. curses supplies names for special keys, so you can test c for equality with such readable constants as curses.KEY_HOME (the Home special key), curses.KEY_LEFT (the left-arrow special key), and so on. The list of all curses special-key names (about 100 of them) is in Python’s free documentation, specifically, in the Python Library Reference, Section 6.13.3 Constants, for current versions of Python. If you have set window w to no-delay mode by calling w .nodelay(True), w .getch raises an exception if no keystroke is ready. By default, however, w .getch waits until the user hits a key.

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.