I'm porting some code from C++ to Delphi Pascal and got stuck when I couldn't find the Delphi equivalent of kbhit on a console application. I've been scouring the net for the last 2 days and can't seem to find anything. Guess nobody writes console apps nowadays.
Anyway, what I've come up with is a crude 2 thread jobby. One thread resets a variable and sits on a readln. When the user hits return, it sets the variable. The other thread polls the variable. If it is set, then the user has hit return and something else can happen. It is not ideal but it works.
Is there a better way like a kbhit routine?
Alternatively, is it OK practice to pinch the one in the MS DLL (have to find out which DLL first). I'm a bit weary about this one as it is a completely different I/O system and may cause problems (like mixing stdio and iostream in C++).
Anyway, what I've come up with is a crude 2 thread jobby. One thread resets a variable and sits on a readln. When the user hits return, it sets the variable. The other thread polls the variable. If it is set, then the user has hit return and something else can happen. It is not ideal but it works.
Is there a better way like a kbhit routine?
Alternatively, is it OK practice to pinch the one in the MS DLL (have to find out which DLL first). I'm a bit weary about this one as it is a completely different I/O system and may cause problems (like mixing stdio and iostream in C++).