|Skip Navigation Links|
|Exit Print View|
|man pages section 3: Curses Library Functions Oracle Solaris 10 1/13 Information Library|
- get a single-byte character from the terminal
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib \ -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int getch(void);
int wgetch(WINDOW *win);
int mvgetch(int y, int x);
int mvwgetch(WINDOW *win, int y, int x);
Is a pointer to the window associated with the terminal from which the character is to be read.
Is the y (row) coordinate for the position of the character to be read.
Is the x (column) coordinate for the position of the character to be read.
These functions read a single-byte character from the terminal associated with the current or specified window. The results are unspecified if the input is not a single-byte character. If keypad(3XCURSES) 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 on the keypad(3XCURSES) manual page.
If echoing is enabled, then the character is echoed as though it were provided as an input argument to addch(3XCURSES), except for the following characters:
The input is interpreted as follows: unless the cursor already was in column 0, <backspace> moves the cursor one column toward the start of the current line and any characters after the <backspace> are added or inserted starting there. The character at the resulting cursor position it then deleted as though delch(3XCURSES) were called, except that if the cursor was originally in the first column of the line, the user is alerted as though beep(3XCURSES) were called.
The user is alerted as though beep() were called. Information concerning the function keys is not returned to the caller.
If the current or specified window is not a pad, and it has been moved modified since the last refresh operation, then it will be refreshed before another character is read.
The following is a list of tokens for function keys that are returned by the getch() set of functions if keypad handling is enabled (some terminals may not support all tokens).
Upon successful completion, these functions return the single-byte character, KEY_ value, or ERR. When in the nodelay mode and no data is available, ERR is returned.
No errors are defined.
Applications should not define the escape key by itself as a single-character function.
When using these functions, nocbreak mode (cbreak(3XCURSES)) and echo mode (echo(3XCURSES)) should not be used at the same time. Depending on the state of the terminal when each character is typed, the application may produce undesirable results.
See attributes(5) for descriptions of the following attributes: