MCPcopy Create free account
hub / github.com/Effect-TS/effect / handleKeypress

Function handleKeypress

packages/platform/node-shared/src/NodeTerminal.ts:94–103  ·  view source on GitHub ↗
(s: string | undefined, k: readline.Key)

Source from the content-addressed store, hash-verified

92 const readInput = Effect.gen(function*() {
93 const queue = yield* Queue.make<Terminal.UserInput, Cause.Done>()
94 const handleKeypress = (s: string | undefined, k: readline.Key) => {
95 const userInput = {
96 input: Option.fromUndefinedOr(s),
97 key: { name: k.name ?? "", ctrl: !!k.ctrl, meta: !!k.meta, shift: !!k.shift }
98 }
99 Queue.offerUnsafe(queue, userInput)
100 if (shouldQuit(userInput)) {
101 Queue.endUnsafe(queue)
102 }
103 }
104 // Deno's `process.stdin` shim does not keep the event loop alive, so a
105 // program blocked on input can exit before `end` is ever delivered. A
106 // timer holds the loop open for as long as this reader is active.

Callers

nothing calls this directly

Calls 2

shouldQuitFunction · 0.85
offerUnsafeMethod · 0.80

Tested by

no test coverage detected