It does this by forward scanning the input buffer and matching it against a dictionary it maintains.
One then types a space to move the character from the input buffer onto the screen.
Peekable reads (read without removing from pipe's input buffer)
(In practice, it might provide better performance to make the output buffer larger and the input buffers slightly smaller.)
The input buffer is a queue where events are stored (from keyboard, mouse etc.).
Starting at the near clip plane of the camera, the whole scene is traced and sampling values are accumulated into the input buffer.
Every so often it looks at the input buffer, and it sees characters, new characters are appearing.
Pressed keys are stored in an input buffer.
The line to be edited is then left in the input buffer.
The input buffer is around 127 bytes long.