MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / holdKey

Function holdKey

source code/utils/computerUse/executor.ts:477–509  ·  view source on GitHub ↗
(keyNames: string[], durationMs: number)

Source from the content-addressed store, hash-verified

475 },
476
477 async holdKey(keyNames: string[], durationMs: number): Promise<void> {
478 const input = requireComputerUseInput()
479 // Press/release each wrapped in drainRunLoop; the sleep sits outside so
480 // durationMs isn't bounded by drainRunLoop's 30s timeout. `pressed`
481 // tracks which presses landed so a mid-press throw still releases
482 // everything that was actually pressed.
483 //
484 // `orphaned` guards against a timeout-orphan race: if the press-phase
485 // drainRunLoop times out while the esc-hotkey pump-retain keeps the
486 // pump running, the orphaned lambda would continue pushing to `pressed`
487 // after finally's releasePressed snapshotted the length — leaving keys
488 // stuck. The flag stops the lambda at the next iteration.
489 const pressed: string[] = []
490 let orphaned = false
491 try {
492 await drainRunLoop(async () => {
493 for (const k of keyNames) {
494 if (orphaned) return
495 // Bare Escape: notify the CGEventTap so it doesn't fire the
496 // abort callback for a model-synthesized press. Same as key().
497 if (isBareEscape([k])) {
498 notifyExpectedEscape()
499 }
500 await input.key(k, 'press')
501 pressed.push(k)
502 }
503 })
504 await sleep(durationMs)
505 } finally {
506 orphaned = true
507 await drainRunLoop(() => releasePressed(input, pressed))
508 }
509 },
510
511 async type(text: string, opts: { viaClipboard: boolean }): Promise<void> {
512 const input = requireComputerUseInput()

Callers

nothing calls this directly

Calls 6

requireComputerUseInputFunction · 0.85
drainRunLoopFunction · 0.85
isBareEscapeFunction · 0.85
notifyExpectedEscapeFunction · 0.85
sleepFunction · 0.85
releasePressedFunction · 0.85

Tested by

no test coverage detected