MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / handleKeyDown

Function handleKeyDown

src/components/ui/ConfirmationHost.tsx:81–105  ·  view source on GitHub ↗
(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

79 if (!pending) return;
80
81 const handleKeyDown = (event: KeyboardEvent) => {
82 if (event.key === 'Escape') {
83 settle(false);
84 return;
85 }
86
87 if (event.key !== 'Tab') return;
88
89 const focusable = Array.from(
90 dialogRef.current?.querySelectorAll<HTMLButtonElement>('button:not([disabled])') ?? []
91 );
92 if (focusable.length === 0) return;
93
94 const first = focusable[0];
95 const last = focusable[focusable.length - 1];
96 const activeElement = document.activeElement;
97
98 if (event.shiftKey && activeElement === first) {
99 event.preventDefault();
100 last.focus();
101 } else if (!event.shiftKey && activeElement === last) {
102 event.preventDefault();
103 first.focus();
104 }
105 };
106
107 document.addEventListener('keydown', handleKeyDown);
108 return () => document.removeEventListener('keydown', handleKeyDown);

Callers

nothing calls this directly

Calls 2

settleFunction · 0.85
preventDefaultMethod · 0.65

Tested by

no test coverage detected