1getch(3XCURSES) X/Open Curses Library Functions getch(3XCURSES)
2
3
4
6 getch, wgetch, mvgetch, mvwgetch - get a single-byte character from the
7 terminal
8
10 cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib \
11 -R /usr/xpg4/lib -lcurses [ library... ]
12
13 c89 [ flag... ] file... -lcurses [ library... ]
14
15 #include <curses.h>
16
17 int getch(void);
18
19
20 int wgetch(WINDOW *win);
21
22
23 int mvgetch(int y, int x);
24
25
26 int mvwgetch(WINDOW *win, int y, int x);
27
28
30 win Is a pointer to the window associated with the terminal from
31 which the character is to be read.
32
33
34 y Is the y (row) coordinate for the position of the character to
35 be read.
36
37
38 x Is the x (column) coordinate for the position of the character
39 to be read.
40
41
43 These functions read a single-byte character from the terminal associ‐
44 ated with the current or specified window. The results are unspecified
45 if the input is not a single-byte character. If keypad(3XCURSES) is
46 enabled, these functions respond to the pressing of a function key by
47 returning the corresponding KEY_ value defined in <curses.h>
48
49
50 Processing of terminal input is subject to the general rules described
51 on the keypad(3XCURSES) manual page.
52
53
54 If echoing is enabled, then the character is echoed as though it were
55 provided as an input argument to addch(3XCURSES), except for the fol‐
56 lowing characters:
57
58 <backspace> The input is interpreted as follows: unless the cursor
59 already was in column 0, <backspace> moves the cursor
60 one column toward the start of the current line and
61 any characters after the <backspace> are added or
62 inserted starting there. The character at the result‐
63 ing cursor position it then deleted as though
64 delch(3XCURSES) were called, except that if the cursor
65 was originally in the first column of the line, the
66 user is alerted as though beep(3XCURSES) were called.
67
68
69 Function keys The user is alerted as though beep() were called.
70 Information concerning the function keys is not
71 returned to the caller.
72
73
74
75 If the current or specified window is not a pad, and it has been moved
76 modified since the last refresh operation, then it will be refreshed
77 before another character is read.
78
79 Constant Values for Function Keys
80 The following is a list of tokens for function keys that are returned
81 by the getch() set of functions if keypad handling is enabled (some
82 terminals may not support all tokens).
83
84
85
86
87 ┌───────────────────────────────────────────────────────────┐
88 │ Constant Description │
89 ├───────────────────────────────────────────────────────────┤
90 │KEY_BREAK Break key │
91 │KEY_DOWN The down arrow key │
92 │KEY_UP The up arrow key │
93 │KEY_LEFT The left arrow key │
94 │KEY_RIGHT The right arrow key │
95 │KEY_HOME Home key │
96 │KEY_BACKSPACE Backspace │
97 │KEY_F0 Function keys. Space for 64 keys is │
98 │ reserved. │
99 │KEY_F(n) For 0 <= n <= 63 │
100 │KEY_DL Delete line │
101 │KEY_IL Insert line │
102 │KEY_DC Delete character │
103 │KEY_IC Insert char or enter insert mode │
104 │KEY_EIC Exit insert char mode │
105 │KEY_CLEAR Clear screen │
106 │KEY_EOS Clear to end of screen │
107 │KEY_EOL Clear to end of line │
108 │KEY_SF Scroll 1 line forward │
109 │ KEY_SR Scroll 1 line backwards │
110 │KEY_NPAGE Next page │
111 │KEY_PPAGE Previous page │
112 │KEY_STAB Set tab │
113 │KEY_CTAB Clear tab │
114 │KEY_CATAB Clear all tabs │
115 │KEY_ENTER Enter or send │
116 │KEY_SRESET Soft (partial) reset │
117 │KEY_RESET Reset or hard reset │
118 │KEY_PRINT Print or copy │
119 │KEY_LL Home down or bottom (lower left) │
120 │KEY_A1 Upper left of keypad │
121 │KEY_A3 Upper right of keypad │
122 │KEY_B2 Center of keypad │
123 │KEY_C1 Lower left of keypad │
124 │KEY_C3 Lower right of keypad │
125 │KEY_BTAB Back tab │
126 │KEY_BEG Beginning key │
127 │KEY_CANCEL Cancel key │
128 │KEY_CLOSE Close key │
129 │KEY_COMMAND Cmd (command) key │
130 │KEY_COPY Copy key │
131 │KEY_CREATE Create key │
132 │KEY_END End key │
133 │KEY_EXIT Exit key │
134 │KEY_FIND Find key │
135 │KEY_HELP Help key │
136 │KEY_MARK Mark key │
137 │KEY_MESSAGE Message key │
138 │KEY_MOVE Move key │
139 │KEY_NEXT Next object key │
140 │KEY_OPEN Open key │
141 │KEY_OPTIONS Options key │
142 │KEY_PREVIOUS Previous object key │
143 │KEY_REDO Redo key │
144 │KEY_REFERENCE Reference key │
145 │KEY_REFRESH Refresh key │
146 │KEY_REPLACE Replace key │
147 │KEY_RESTART Restart key │
148 │KEY_RESUME Resume key │
149 │KEY_SAVE Save key │
150 │KEY_SBEG Shifted beginning key │
151 │KEY_SCANCEL Shifted cancel key │
152 │KEY_SCOMMAND Shifted command key │
153 │KEY_SCOPY Shifted copy key │
154 │KEY_SCREATE Shifted create key │
155 │KEY_SDC Shifted delete char key │
156 │KEY_SDL Shifted delete line key │
157 │KEY_SELECT Select key │
158 │KEY_SEND Shifted end key │
159 │KEY_SEOL Shifted clear line key │
160 │KEY_SEXIT Shifted exit key │
161 │KEY_SFIND Shifted find key │
162 │KEY_SHELP Shifted help key │
163 │KEY_SHOME Shifted home key │
164 │KEY_SIC Shifted input key │
165 │KEY_SLEFT Shifted left arrow key │
166 │KEY_SMESSAGES Shifted messages key │
167 │KEY_SMOVE Shifted move key │
168 │KEY_SNEXT Shifted next key │
169 │KEY_SOPTIONS Shifted options key │
170 │KEY_SPREVIOUS Shifted previous key │
171 │KEY_SPRINT Shifted print key │
172 │KEY_SREDO Shifted redo key │
173 │KEY_SREPLACE Shifted replace key │
174 │KEY_SRIGHT Shifted right arrow key │
175 │KEY_SRSUME Shifted resume key │
176 │KEY_SSAVE Shifted save key │
177 │KEY_SSUSPEND Shifted suspend key │
178 │KEY_SUNDO Shifted undo key │
179 │KEY_SUSPEND Suspend key │
180 │KEY_UNDO Undo key │
181 └───────────────────────────────────────────────────────────┘
182
184 Upon successful completion, these functions return the single-byte
185 character, KEY_ value, or ERR. When in the nodelay mode and no data is
186 available, ERR is returned.
187
189 No errors are defined.
190
192 Applications should not define the escape key by itself as a single-
193 character function.
194
195
196 When using these functions, nocbreak mode (cbreak(3XCURSES)) and echo
197 mode (echo(3XCURSES)) should not be used at the same time. Depending on
198 the state of the terminal when each character is typed, the application
199 may produce undesirable results.
200
202 See attributes(5) for descriptions of the following attributes:
203
204
205
206
207 ┌─────────────────────────────┬─────────────────────────────┐
208 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
209 ├─────────────────────────────┼─────────────────────────────┤
210 │Interface Stability │Standard │
211 ├─────────────────────────────┼─────────────────────────────┤
212 │MT-Level │Unsafe │
213 └─────────────────────────────┴─────────────────────────────┘
214
216 cbreak(3XCURSES), echo(3XCURSES), halfdelay(3XCURSES), key‐
217 pad(3XCURSES), libcurses(3XCURSES), nodelay(3XCURSES), notime‐
218 out(3XCURSES), raw(3XCURSES), timeout(3XCURSES), attributes(5), stan‐
219 dards(5)
220
221
222
223SunOS 5.11 5 Jun 2002 getch(3XCURSES)