MCPcopy
hub / github.com/Effect-TS/effect / handleKeypress

Function handleKeypress

packages/platform-node-shared/src/internal/terminal.ts:50–59  ·  view source on GitHub ↗
(s: string | undefined, k: readline.Key)

Source from the content-addressed store, hash-verified

48 yield* RcRef.get(rlRef)
49 const mailbox = yield* Mailbox.make<Terminal.UserInput>()
50 const handleKeypress = (s: string | undefined, k: readline.Key) => {
51 const userInput = {
52 input: Option.fromNullable(s),
53 key: { name: k.name ?? "", ctrl: !!k.ctrl, meta: !!k.meta, shift: !!k.shift }
54 }
55 mailbox.unsafeOffer(userInput)
56 if (shouldQuit(userInput)) {
57 mailbox.unsafeDone(Exit.void)
58 }
59 }
60 yield* Effect.addFinalizer(() => Effect.sync(() => stdin.off("keypress", handleKeypress)))
61 stdin.on("keypress", handleKeypress)
62 return mailbox as Mailbox.ReadonlyMailbox<Terminal.UserInput>

Callers

nothing calls this directly

Calls 3

shouldQuitFunction · 0.85
unsafeDoneMethod · 0.80
unsafeOfferMethod · 0.65

Tested by

no test coverage detected