
Last time I tried something like this [on Windows], it didn't seem to work. I wanted to trap arrow keys and so forth, but they seem to be being used for input history. (I.e., pressing the up-arrow produces previously-entered lines of text, and none of this appears to be reaching the Haskell program itself.) Has this changed since I tried it last year?
Doesn't work in windows, at least up till 6.10.1. There's a work-around though. {-# LANGUAGE ForeignFunctionInterface #-} import Data.Char import Control.Monad (liftM, forever) import Foreign.C.Types getHiddenChar = liftM (chr.fromEnum) c_getch foreign import ccall unsafe "conio.h getch" c_getch :: IO CInt main = do forever $ do c <- getHiddenChar putStrLn $ show (fromEnum c)