
main = do hSetBuffering stdin NoBuffering; c <- getChar Your problem is that by default, POSIX environments use line buffering on stdin queuing up until it sees a carriage return before sending it to the
You want to use:
process. Which is in this case, your code.
-Edward Kmett
On Tue, Mar 31, 2009 at 3:38 PM, Andrew Coppin
I ran the following program:
module Main where
main = do putStrLn "Key" c <- getChar print c main
Unfortunately, it doesn't do what I was hoping. Specifically, it only returns any data when I hit [return]. It also seems to be giving me a command history somehow. Special keys (e.g., arrow keys, backspace, escape) don't get through to the application.
I'm trying to write a program that uses individual keys as commands. What's the correct way to get this to work?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe