1curs_getch(3CURSES)        Curses Library Functions        curs_getch(3CURSES)
2
3
4

NAME

6       curs_getch,  getch,  wgetch,  mvgetch, mvwgetch, ungetch - get (or push
7       back) characters from curses terminal keyboard
8

SYNOPSIS

10       cc [ flag ... ] file ... -lcurses [ library ... ]
11       #include <curses.h>
12
13       int getch(void);
14
15
16       int wgetch(WINDOW *win);
17
18
19       int mvgetch(int y, int x);
20
21
22       int mvwgetch(WINDOW *win, int y, int x);
23
24
25       int ungetch(int ch);
26
27

DESCRIPTION

29       With the getch(), wgetch(), mvgetch(), and mvwgetch() routines a  char‐
30       acter is read from the terminal associated with the window. In no-delay
31       mode, if no input is waiting, the value ERR is returned. In delay mode,
32       the  program waits until the system passes text through to the program.
33       Depending on the setting of  cbreak(),  this  is  after  one  character
34       (cbreak  mode),  or  after  the first newline (nocbreak mode). In half-
35       delay mode, the program waits until a character is typed or the  speci‐
36       fied  timeout has been reached. Unless noecho() has been set, the char‐
37       acter will also be echoed into the designated window.
38
39
40       If the window is not a pad, and it has been moved or modified since the
41       last call to wrefresh(), wrefresh() will be called before another char‐
42       acter is read.
43
44
45       If keypad() is TRUE, and a function key is pressed, the token for  that
46       function  key is returned instead of the raw characters. Possible func‐
47       tion keys are defined in <curses.h> with integers beginning with  0401,
48       whose names begin with KEY_. If a character that could be the beginning
49       of a function key (such as escape) is received, curses sets a timer. If
50       the  remainder  of  the sequence does not come in within the designated
51       time, the character is passed  through;  otherwise,  the  function  key
52       value  is  returned. For this reason, many terminals experience a delay
53       between the time a user presses  the  escape  key  and  the  escape  is
54       returned  to  the  program. Since tokens returned by these routines are
55       outside the ASCII range, they are not printable.
56
57
58       The ungetch() routine places  ch  back  onto  the  input  queue  to  be
59       returned by the next call to wgetch().
60
61   Function Keys
62       The  following  function keys, defined in <curses.h>, might be returned
63       by getch() if keypad() has been enabled. Note that not all of these may
64       be supported on a particular terminal if the terminal does not transmit
65       a unique code when the key is pressed or if the definition for the  key
66       is not present in the terminfo database.
67
68
69
70
71                  Name                           Key name
72       ───────────────────────────────────────────────────────────────
73       KEY_BREAK                     Break key
74       KEY_DOWN                      The four arrow keys ...
75       KEY_UP
76       KEY_LEFT
77       KEY_RIGHT
78       KEY_HOME                      Home key (upward+left arrow)
79       KEY_BACKSPACE                 Backspace
80       KEY_F0                        Function keys; space for 64 keys
81                                     is reserved.
82       KEY_F(n)                      For 0 ≤ n ≤ 63
83       KEY_DL                        Delete line
84       KEY_IL                        Insert line
85       KEY_DC                        Delete character
86       KEY_IC                        Insert char or enter insert mode
87       KEY_EIC                       Exit insert char mode
88       KEY_CLEAR                     Clear screen
89       KEY_EOS                       Clear to end of screen
90       KEY_EOL                       Clear to end of line
91       KEY_SF                        Scroll 1 line forward
92        KEY_SR                       Scroll 1 line backward (reverse)
93       KEY_NPAGE                     Next page
94       KEY_PPAGE                     Previous page
95       KEY_STAB                      Set tab
96       KEY_CTAB                      Clear tab
97       KEY_CATAB                     Clear all tabs
98       KEY_ENTER                     Enter or send
99       KEY_SRESET                    Soft (partial) reset
100       KEY_RESET                     Reset or hard reset
101       KEY_PRINT                     Print or copy
102       KEY_LL                        Home  down  or   bottom   (lower
103                                     left).  Keypad  is arranged like
104                                     this: (Row 1) A1   up    A3 (Row
105                                     2)  left   B2   right (Row 3) C1
106                                     down   C3
107       KEY_A1                        Upper left of keypad
108       KEY_A3                        Upper right of keypad
109       KEY_B2                        Center of keypad
110       KEY_C1                        Lower left of keypad
111       KEY_C3                        Lower right of keypad
112       KEY_BTAB                      Back tab key
113       KEY_BEG                       Beg(inning) key
114       KEY_CANCEL                    Cancel key
115       KEY_CLOSE                     Close key
116       KEY_COMMAND                   Cmd (command) key
117       KEY_COPY                      Copy key
118       KEY_CREATE                    Create key
119       KEY_END                       End key
120       KEY_EXIT                      Exit key
121       KEY_FIND                      Find key
122       KEY_HELP                      Help key
123       KEY_MARK                      Mark key
124       KEY_MESSAGE                   Message key
125       KEY_MOVE                      Move key
126       KEY_NEXT                      Next object key
127       KEY_OPEN                      Open key
128       KEY_OPTIONS                   Options key
129       KEY_PREVIOUS                  Previous object key
130       KEY_REDO                      Redo key
131       KEY_REFERENCE                 Reference key
132
133       KEY_REFRESH                   Refresh key
134       KEY_REPLACE                   Replace key
135       KEY_RESTART                   Restart key
136       KEY_RESUME                    Resume key
137       KEY_SAVE                      Save key
138       KEY_SBEG                      Shifted beginning key
139       KEY_SCANCEL                   Shifted cancel key
140       KEY_SCOMMAND                  Shifted command key
141       KEY_SCOPY                     Shifted copy key
142       KEY_SCREATE                   Shifted create key
143       KEY_SDC                       Shifted delete char key
144       KEY_SDL                       Shifted delete line key
145       KEY_SELECT                    Select key
146       KEY_SEND                      Shifted end key
147       KEY_SEOL                      Shifted clear line key
148       KEY_SEXIT                     Shifted exit key
149       KEY_SFIND                     Shifted find key
150       KEY_SHELP                     Shifted help key
151       KEY_SHOME                     Shifted home key
152       KEY_SIC                       Shifted input key
153       KEY_SLEFT                     Shifted left arrow key
154       KEY_SMESSAGE                  Shifted message key
155       KEY_SMOVE                     Shifted move key
156       KEY_SNEXT                     Shifted next key
157       KEY_SOPTIONS                  Shifted options key
158       KEY_SPREVIOUS                 Shifted prev key
159       KEY_SPRINT                    Shifted print key
160       KEY_SREDO                     Shifted redo key
161       KEY_SREPLACE                  Shifted replace key
162       KEY_SRIGHT                    Shifted right arrow
163       KEY_SRSUME                    Shifted resume key
164       KEY_SSAVE                     Shifted save key
165       KEY_SSUSPEND                  Shifted suspend key
166       KEY_SUNDO                     Shifted undo key
167       KEY_SUSPEND                   Suspend key
168       KEY_UNDO                      Undo key
169
170

RETURN VALUES

172       All routines return the integer ERR upon failure.  The  ungetch()  rou‐
173       tine  returns  an  integer value other than ERR upon successful comple‐
174       tion.  The other routines return the next input character  or  function
175       key code upon successful completion.
176

ATTRIBUTES

178       See attributes(5) for descriptions of the following attributes:
179
180
181
182
183       ┌─────────────────────────────┬─────────────────────────────┐
184       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
185       ├─────────────────────────────┼─────────────────────────────┤
186       │MT-Level                     │Unsafe                       │
187       └─────────────────────────────┴─────────────────────────────┘
188

SEE ALSO

190       curs_inopts(3CURSES),     curs_move(3CURSES),    curs_refresh(3CURSES),
191       curses(3CURSES), attributes(5)
192

NOTES

194       The header <curses.h> automatically includes the headers  <stdio.h> and
195       <unctrl.h>.
196
197
198       Use of the escape key for a single character function is discouraged.
199
200
201       When  using  getch(), wgetch(), mvgetch(), or mvwgetch(), nocbreak mode
202       (nocbreak()) and  echo mode (echo()) should not be  used  at  the  same
203       time.  Depending  on the state of the tty driver when each character is
204       typed, the program may produce undesirable results.
205
206
207       Note that getch(), mvgetch(), and mvwgetch() may be macros.
208
209
210
211SunOS 5.11                        31 Dec 1996              curs_getch(3CURSES)
Impressum