Hi folks,
I've been playing around with some ANSI stuff (like colors etc.) in java and php (from scratch) and I'm trying to find a way to basically wait for a key press. I'd like to have something like the following pseudo code at the end of my main event loop:
If (KeyPressed)
Begin
var event = new KeyboardEvent();
event.Key = ReadKey();
this.BubbleEvent(event);
End
But everything I've been trying over the last couple days fails because the key presses only become available on STDIN after the user has pressed enter.
It doesn't matter much what language you answer in, but java
, php
, plain old c
or c#
would be nicest, and I cannot use any really spiffy library stuff because I need to port it to all four of those languages... I need this to work over a telnet
or ssh
connection, but my research so far suggests it is impossible unless you're working on the local machine.
Please prove me wrong.