MCPcopy Create free account
hub / github.com/code100x/cms / handleKeyDown

Function handleKeyDown

src/components/Signin.tsx:97–109  ·  view source on GitHub ↗
(e: React.KeyboardEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

95
96 // Handle keyboard events for navigating and selecting suggestions
97 const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
98 if (e.key === 'Enter' && focusedIndex >= 0 && suggestedDomains.length > 0) {
99 handleSuggestionClick(suggestedDomains[focusedIndex]);
100 } else if (e.key === 'ArrowDown') {
101 e.preventDefault();
102 setFocusedIndex((prevIndex) =>
103 Math.min(prevIndex + 1, suggestedDomains.length - 1),
104 );
105 } else if (e.key === 'ArrowUp') {
106 e.preventDefault();
107 setFocusedIndex((prevIndex) => Math.max(prevIndex - 1, 0));
108 }
109 };
110
111 const handleSubmit = async (e?: React.FormEvent<HTMLButtonElement>) => {
112 const loadId = toast.loading('Signing in...');

Callers

nothing calls this directly

Calls 1

handleSuggestionClickFunction · 0.85

Tested by

no test coverage detected