I need a method that waits x seconds for a user to press a key. If they key is pressed, it returns the character. If no key is pressed after x seconds, the method returns some non-character value (-1 perhaps?).
This method should run in a DOS application, not a windows application (the project I need the method for is intended to be run from AUTOEXEC.BAT).
I've attempted writing this myself but I'll be damned if I can work out how to do it. Every input command/method I've tried requires the user to press a key *and then press Enter*. This is no good to me; I want the program to wait for a single keystroke and if none is given to carry on anyway (with a different result).
100 points in anticipation of a quick answer; I get bored quickly and will give up if this takes too long.