getch, wgetch, mvgetch, mvwgetch - get a single-byte character from the terminal
#include <curses.h> int getch(void); int mvgetch(int y, int x); int mvwgetch(WINDOW *win, int y, int x); int wgetch(WINDOW *win);
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() 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
If echoing is enabled, then the character is echoed as though it were provided as an input argument to addch(), except for the following characters:
<backspace>, <left-arrow> and the current erase character: The input is interpreted as specified in and then the character at the resulting cursor position is deleted as though were called, except that if the cursor was originally in the first column of the line, then the user is alerted as though were called. Function keys The user is alerted as though 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 or modified since the last refresh operation, then it will be refreshed before another character is read.
Upon successful completion getch(), mvgetch(), mvwgetch() and wgetch() 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 (.Fn nocbreak ) and echo mode (.Fn 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.
Input Processing, cbreak(), doupdate(), insch(), <curses.h>.