How do I write a function keypressed(), that returns 0 if no char is in the input queue and returns the character otherwise? Keypressed() should not block, and should leave the terminal in its initial state after returning. I can't use curses and have played around with ioctl, but its really slow. Any suggestions? Patrik