Thursday, 5 September 2019

Getting Key Strokes from the Console

This post provides a function getchar() which get key strokes from the console without requiring the users to press the [Enter] key. It can be used as an keyboard input function in a program written for command line interface (CLI).

Note that getchar() can detect normal keys such as letters and digits, as well as some special keys such as arrow keys and backspace. After some modification, it can also detect ctrl-[key], alt-[key], and other special command keys.

Source Code




No comments:

Post a Comment