MCPcopy Create free account
hub / github.com/anus-dev/ANUS / handleKeypress

Function handleKeypress

packages/cli/src/ui/contexts/KeypressContext.tsx:175–305  ·  view source on GitHub ↗
(_: unknown, key: Key)

Source from the content-addressed store, hash-verified

173 };
174
175 const handleKeypress = (_: unknown, key: Key) => {
176 if (key.name === 'return' && waitingForEnterAfterBackslash) {
177 if (backslashTimeout) {
178 clearTimeout(backslashTimeout);
179 backslashTimeout = null;
180 }
181 waitingForEnterAfterBackslash = false;
182 broadcast({
183 ...key,
184 shift: true,
185 sequence: '\r', // Corrected escaping for newline
186 });
187 return;
188 }
189
190 if (key.sequence === '\\' && !key.name) {
191 // Corrected escaping for backslash
192 waitingForEnterAfterBackslash = true;
193 backslashTimeout = setTimeout(() => {
194 waitingForEnterAfterBackslash = false;
195 backslashTimeout = null;
196 broadcast(key);
197 }, BACKSLASH_ENTER_DETECTION_WINDOW_MS);
198 return;
199 }
200
201 if (waitingForEnterAfterBackslash && key.name !== 'return') {
202 if (backslashTimeout) {
203 clearTimeout(backslashTimeout);
204 backslashTimeout = null;
205 }
206 waitingForEnterAfterBackslash = false;
207 broadcast({
208 name: '',
209 sequence: '\\',
210 ctrl: false,
211 meta: false,
212 shift: false,
213 paste: false,
214 });
215 }
216
217 if (['up', 'down', 'left', 'right'].includes(key.name)) {
218 broadcast(key);
219 return;
220 }
221
222 if (
223 (key.ctrl && key.name === 'c') ||
224 key.sequence === `${ESC}${KITTY_CTRL_C}`
225 ) {
226 kittySequenceBuffer = '';
227 if (key.sequence === `${ESC}${KITTY_CTRL_C}`) {
228 broadcast({
229 name: 'c',
230 ctrl: true,
231 meta: false,
232 shift: false,

Callers 1

handleRawKeypressFunction · 0.85

Calls 4

broadcastFunction · 0.85
parseKittySequenceFunction · 0.85
logKittySequenceOverflowFunction · 0.85
getDebugModeMethod · 0.80

Tested by

no test coverage detected