MCPcopy
hub / github.com/claude-code-best/claude-code / handleKeyDown

Function handleKeyDown

src/hooks/useSearchInput.ts:103–349  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

101 }, [])
102
103 const handleKeyDown = (e: KeyboardEvent): void => {
104 if (!isActive) return
105
106 const cursor = Cursor.fromText(query, effectiveColumns, cursorOffset)
107
108 // Check passthrough ctrl keys
109 if (e.ctrl && passthroughCtrlKeys.includes(e.key.toLowerCase())) {
110 return
111 }
112
113 // Reset kill accumulation for non-kill keys
114 if (!isKillKey(e)) {
115 resetKillAccumulation()
116 }
117
118 // Reset yank state for non-yank keys
119 if (!isYankKey(e)) {
120 resetYankState()
121 }
122
123 // Exit conditions
124 if (e.key === 'return' || e.key === 'down') {
125 e.preventDefault()
126 onExit()
127 return
128 }
129 if (e.key === 'up') {
130 e.preventDefault()
131 if (onExitUp) {
132 onExitUp()
133 }
134 return
135 }
136 if (e.key === 'escape') {
137 e.preventDefault()
138 if (onCancel) {
139 onCancel()
140 } else if (query.length > 0) {
141 setQueryState('')
142 setCursorOffset(0)
143 } else {
144 onExit()
145 }
146 return
147 }
148
149 // Backspace/Delete
150 if (e.key === 'backspace') {
151 e.preventDefault()
152 if (e.meta) {
153 // Meta+Backspace: kill word before
154 const { cursor: newCursor, killed } = cursor.deleteWordBefore()
155 pushToKillRing(killed, 'prepend')
156 setQueryState(newCursor.text)
157 setCursorOffset(newCursor.offset)
158 return
159 }
160 if (query.length === 0) {

Callers 1

useSearchInputFunction · 0.70

Calls 15

resetKillAccumulationFunction · 0.85
resetYankStateFunction · 0.85
onExitFunction · 0.85
pushToKillRingFunction · 0.85
getLastKillFunction · 0.85
recordYankFunction · 0.85
yankPopFunction · 0.85
updateYankLengthFunction · 0.85
fromTextMethod · 0.80
preventDefaultMethod · 0.80
deleteWordBeforeMethod · 0.80
backspaceMethod · 0.80

Tested by

no test coverage detected