On 10/23/06, Neil Mitchell <[EMAIL PROTECTED]> wrote:
Hi

>    getChar doesn't return until I press Enter. I need something that
> returns immediately after I press any key.

It's a problem with buffering:

hSetBuffering stdin NoBuffering

This usually doesn't work on Windows:

GHC 6.4.2 and 6.6: requires <enter>
Hugs (console) Sept. 2006: requires <enter>
WinHugs (GUI) Sept. 2006: works as expected

But it seems to work on Linux:
GHC 6.4.1 on Ubuntu 6.06: works as expected
GHC 6.6 on Ubuntu 6.06: works as expected

I am really interested in hearing of a solution that works on all platforms.

> import IO
> main = do
>    hSetBuffering stdin NoBuffering
>    hGetChar stdin

Regards,
Brian

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to