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

Function handleKeyDown

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected