With the following command you can register some callback for stdin:
fileevent stdin readable thatCallback
This means that during the execution of the update command it will evaluate thatCallback time after time while there is input available at stdin.
How can I check if input is available at stdin ?
You simply read/gets from stdin inside your callback. Basically the pattern goes like this snippet from the fileevent example from Kevin Kenny: