From de80196a45139fccd1512e7c08866d826c7b5be1 Mon Sep 17 00:00:00 2001 From: ZachDreamZ Date: Thu, 25 Jun 2026 12:16:01 +0800 Subject: [PATCH] feat: add 'n' keyboard shortcut to open add-application modal Press 'n' (when not focused on an input or textarea) on the Applications page to open the Add-application modal. - Added useEffect hook to listen for keydown events - Guards against triggering when typing in form fields - Escape key already closes the modal via the Modal component Closes #7 --- frontend/src/pages/ApplicationsPage.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frontend/src/pages/ApplicationsPage.tsx b/frontend/src/pages/ApplicationsPage.tsx index e7d73cd..e5203a9 100644 --- a/frontend/src/pages/ApplicationsPage.tsx +++ b/frontend/src/pages/ApplicationsPage.tsx @@ -1,4 +1,6 @@ import { useMemo, useState, type FormEvent } from 'react'; + +import { useEffect, useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { ApplicationForm } from '@/components/forms/ApplicationForm'; @@ -43,6 +45,22 @@ export function ApplicationsPage() { const [importUrl, setImportUrl] = useState(''); const [importError, setImportError] = useState(null); + // Keyboard shortcut: press 'n' to open the add-application modal + // (only when no input/textarea is focused) + useEffect(() => { + const onKeyDown = (e: KeyboardEvent) => { + if (e.key !== 'n') return; + const el = document.activeElement; + if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || (el as HTMLElement).isContentEditable)) { + return; + } + e.preventDefault(); + setCreating(true); + }; + window.addEventListener('keydown', onKeyDown); + return () => window.removeEventListener('keydown', onKeyDown); + }, []); + const { data, isLoading, isError, refetch } = useApplications({ q: debouncedSearch || undefined, page_size: 100,