let get_key () =
match Ketrew_configuration.use_cbreak () with
| true ->
with_cbreak (fun () ->
wrap_deferred (fun () -> Lwt_io.read_char Lwt_io.stdin)
~on_exn:(fun e -> (`Failure "get_key")))
| false ->
wrap_deferred
~on_exn:(fun e -> (`Failure "get_key"))
begin fun () ->
let open Lwt in
Lwt_io.read_line Lwt_io.stdin
>>= fun l ->
begin match String.get l 0 with
| Some c -> return c
| None -> return '\n'
end
end