Ocaml解析读取stdin文件描述符

时间:2017-01-07 08:22:20

标签: unix ocaml stdin file-descriptor

我尝试使用以下代码解析stdin filescriptor中的读取:

let run () =
  let b = Bytes.create 1024 in
  let stdin_fd = Lwt_unix.stdin in
  let stdout_fd = Lwt_unix.stdout in
  (Lwt_unix.read stdin_fd b 0 1024) >>=
     (fun _  ->
        print_endline "done";
        print_endline b;
        print_endline "ok?";
        Lwt.return ())

当我在终端中键入一些文本并按Enter键时,它会打印我输入的文本。问题是我想获得有关我输入的密钥的更多信息。让我们说:ctrl + v或其他什么,如何从Lwt_unix.read中获取这些信息?目前我只收到我输入的字符,如何知道例如ctrl - 键(或shift或esc)是否被按下了?

0 个答案:

没有答案
相关问题