But I think I should to try to implement it without using standard
stdio.h function, just pure C programming, if you know what I mean....
What could you advice on that?
The problem is implementing getchar(). Once ypu've done that, it's
trivial to build gets() on top.
I don't know exactly how the system works myself these days, but
essentially it goes something like this. The keyboard sends an
interrupt to the processor when a key is depressed, and another one
when it is released. In the interrupt routine, the processor can query
the state of the keyboard, finding out which keys are depressed. That
raw information is passed to a higher-level process, which translates
the pattern of physical key presses into a "keyborad buffer"
contianing a queue of characters. Applications level-programs then
extract characters from the queue. There's some system for sending the
right characters to the program which has keyboard focus at the time.
Virtually all of this programming can be done in C, or C with a few
extensions and assembly calls. However it's imossible to do it without
an intimate knowledge of the system. Whilst not excessively
complicated or difficult, it tends to be hard to find the information
and it's not very accessibly-presented, because very few people have a
need to write keyborad drivers.