package keyseq

  1. Overview
  2. Docs
Deterministic planner for human-like typing

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1.0.tar.gz
md5=646a1d3bab24631f8459ae5f2c37578f
sha512=5001a58307d0ccaf20ca4b198f52d5ccfdf1b62ed6b0a9acab280fc147ecddd9bea0a39ace0933d1dc858a6aa981d06609e40e75225cef8392cdb8be96df9a09

Description

keyseq turns a string into a deterministic sequence of typing events — insert, delete, delay, idle — for a renderer to play back. All randomness is explicit: the same config, random state, and input always produce the same output.

Tags

typing-simulation human-typing keystroke deterministic

Added to opam-repository:

README

keyseq

Deterministic planner for human-like typing. Turns a string into a sequence of typing events — insert, delete, delay, idle — for a renderer to play back.

demo

Requirements

  • OCaml ≥ 4.14 (uses String.get_utf_8_uchar).

Install

opam install keyseq

Use

let state = Random.State.make [| 1 |] in
match Keyseq.plan Keyseq.default_config state "Hello, world." with
| Ok events -> Keyseq_terminal.run events
| Error (Keyseq.Invalid_utf8 offset) ->
    Printf.eprintf "invalid UTF-8 at byte %d\n" offset

See examples/demo.ml for a complete, runnable example.

Behavior

  • Sleep is an ordinary inter-character delay. Idle is a longer pause, following a sentence-ending . ! ?, during which a renderer may animate the cursor.
  • Mid-clause punctuation (, ; : —) gets a Sleep pause only, no Idle.
  • Typos are only generated for ASCII letters and Cyrillic-block letters; nothing else is ever mistyped, regardless of typo_rate.
  • All randomness is explicit: callers pass a Random.State.t, and the library never calls Random.self_init. Same config, same unconsumed state, same input text — same output, every time.

Failure modes

  • Keyseq.plan returns Error (Invalid_utf8 offset) if the input isn't valid UTF-8. offset is a byte offset.
  • Keyseq.plan raises Invalid_argument if config violates its own preconditions (e.g. max_delay < min_delay) — this is a programmer error, not an input-validation failure.

License

ISC. See LICENSE.

Dependencies (2)

  1. ocaml >= "4.14"
  2. dune >= "3.0"

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None