Ocaml parse read stdin filedescriptor

276 Views Asked by At

I'm trying to parse a read from the stdin filescriptor with the following code:

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 ())

When I type some text in a terminal and hit enter, it prints the text I entered. The problem is I want to get more information about the keys I entered. Let's say I did: ctrl + v or something, how do I get that information out of Lwt_unix.read ? Currently I only get the characters I typed in, how do I know if for example the ctrl-key ( or shift or esc) was pressed?

0

There are 0 best solutions below