I am trying to write a C program that uses Linux system calls to emulate the behaviour of the more
command in the Linux terminal. Since the users might enter commands such as q
to finish the execution, I am trying to find a way in which to read keystrokes from the standard inout without using read(...)
, as I don't want the pressed key to appear on the standard output.
In other words, I want to be able to detect pressed keys without them being written.
I have read that ioctl()
and the termios
struct can somehow be used for this purpose, but I am not sure how they are used (I find the man pages somewhat cryptic).
I have found a few answers to the use of those functions, but all of them seem too complicated. There must be an easier way to detect simple keystrokes, isn't there?