README.rst
1.. zephyr:code-sample:: console_getchar
2 :name: console_getchar()
3
4 Use console_getchar() to read an input character from the console.
5
6Overview
7********
8
9This example shows how to use :c:func:`console_getchar` function.
10Similar to the well-known ANSI C getchar() function,
11:c:func:`console_getchar` either returns the next available input
12character or blocks waiting for one. Using this function, it should be
13fairly easy to port existing ANSI C, POSIX, or Linux applications which
14process console input character by character. The sample also allows to
15see key/character codes as returned by the function.
16
17If you are interested in line by line console input, see
18:zephyr:code-sample:`console_getline`.
19
20
21Requirements
22************
23
24UART console is required to run this sample.
25
26
27Building and Running
28********************
29
30The easiest way to run this sample is using QEMU:
31
32.. zephyr-app-commands::
33 :zephyr-app: samples/subsys/console/getchar
34 :host-os: unix
35 :board: qemu_x86
36 :goals: run
37 :compact:
38
39Now start pressing keys on a keyboard, and they will be printed both as
40hex values and in character form. Be sure to press Enter, Up/Down, etc.
41key to check what control characters are produced for them.
42Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
43