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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access