MCPcopy Create free account
hub / github.com/danvk/webdiff / handleKeydown

Function handleKeydown

ts/codediff/codediff.tsx:235–242  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

233
234 React.useEffect(() => {
235 const handleKeydown = (e: KeyboardEvent) => {
236 if (!isLegitKeypress(e)) return;
237 if (e.code !== 'KeyN' && e.code !== 'KeyP') return;
238 const newSelectedLine = moveUpDown(e.code === 'KeyN' ? 'up' : 'down', selectedLine, ops);
239 if (newSelectedLine !== undefined) {
240 setSelectedLine(newSelectedLine);
241 }
242 };
243 document.addEventListener('keydown', handleKeydown);
244 return () => {
245 document.removeEventListener('keydown', handleKeydown);

Callers

nothing calls this directly

Calls 2

isLegitKeypressFunction · 0.90
moveUpDownFunction · 0.85

Tested by

no test coverage detected