HP-UX Reference (11i v3 07/02) - 3 Library Functions A-M (vol 6)

g
getch(3X) getch(3X)
(CURSES)
NAME
getch, wgetch, mvgetch, mvwgetch get a single-byte character from the terminal
SYNOPSIS
#include <curses.h>
int getch(void);
int mvgetch(int y, int x);
int mvwgetch(WINDOW *win, int y, int x);
int wgetch(WINDOW *win);
DESCRIPTION
These functions read a single-byte character from the terminal associated with the current or specified win-
dow. The results are unspecified if the input is not a single-byte character. If
keypad() is enabled, these
functions respond to the pressing of a function key by returning the corresponding KEY_ value defined in
<curses.h> .
Processing of terminal input is subject to the general rules described in Input Processing in
curses_intro(3X).
If echoing is enabled, then the character is echoed as though it were provided as an input argument to
insch(), except for the following characters:
<backspace>, <left-arrow> and the
current erase character:
The input is interpreted as specified in specialchars
and then the character at the resulting cursor position is
deleted as though delch() were called, except that if
the cursor was originally in the first column of the line,
then the user is alerted as though beep() were called.
The user is alerted as though beep() were called.
Information concerning the function keys is not returned
to the caller.
Function keys
If the current or specified window is not a pad, and it has been moved or modified since the last refresh
operation, then it will be refreshed before another character is read.
RETURN VALUE
Upon successful completion, these functions return the single-byte character, KEY_ value, or ERR.
If in nodelay mode and no data is available, ERR is returned.
ERRORS
No errors are defined.
APPLICATION USAGE
Applications should not define the escape key by itself as a single-character function.
When using these functions, nocbreak mode (nocbreak() ) and echo mode (echo()) should not be used
at the same time. Depending on the state of the terminal when each character is typed, the program may
produce undesirable results.
SEE ALSO
cbreak(3X), doupdate(3X), insch(3X), curses_intro(3X), see Input Processing, <curses.h>.
CHANGE HISTORY
First released in X/Open Curses, Issue 2.
X/Open Curses, Issue 4
The entry is rewritten for clarity. The argument list for the
getch() function is explicitly declared as
void.
HP-UX 11i Version 3: February 2007 1 Hewlett-Packard Company 503