From 3b024ad9f6f74d1e00b1a368870cb8faa1c2e655 Mon Sep 17 00:00:00 2001 From: Aviral Shukla Date: Tue, 7 Jul 2026 23:27:24 +0530 Subject: [PATCH] feat(file-list): open file picker via double-tap E Adds a keyboard shortcut so users can open the native file explorer without reaching for the mouse. Pressing E twice within 700ms triggers the same picker as clicking the empty file list area. Suppressed while a text input has focus so it doesn't fire mid-typing. --- src/components/ui/file-list.tsx | 46 ++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/components/ui/file-list.tsx b/src/components/ui/file-list.tsx index 4625051..2476859 100644 --- a/src/components/ui/file-list.tsx +++ b/src/components/ui/file-list.tsx @@ -1,8 +1,10 @@ import { TextAttributes } from "@opentui/core"; +import { useBindings } from "@opentui/keymap/solid"; import { Index, Show, createResource, createSignal } from "solid-js"; import type { Accessor } from "solid-js"; import { EmptyBorderChars, HIGHLIGHT_ACCENT_COLOR } from "../../constants/constants"; import { useDoubleClick } from "../../hooks/useDoubleClick"; +import { useKeyboardNav } from "../../hooks/useKeyboardNav"; import { getFormattedFileMetadata, handleFileExplorer, openFile } from "../../utils/utils"; import { Label } from "./label"; @@ -26,7 +28,46 @@ interface FileListProps { export function FileList(props: FileListProps) { const fileCount = () => props.files().length; const handleRowClick = useDoubleClick(); + const nav = useKeyboardNav(); + const [isPreviewOpen, setIsPreviewOpen] = createSignal(false); + const [eClickedCount, setEClickedCount] = createSignal(0); + let eTimer: ReturnType | null = null; + + const openFileExplorerFromShortcut = async () => { + if (isPreviewOpen()) return; + const files = await handleFileExplorer(undefined, props.fileType, setIsPreviewOpen); + if (files.length > 0) { + props.onFilesSelected?.(files); + } + }; + + useBindings(() => ({ + priority: 90, + bindings: nav.isInputMode() + ? [] + : [ + { + key: "e", + cmd: () => { + const currentCount = eClickedCount() + 1; + setEClickedCount(currentCount); + if (eTimer) { + clearTimeout(eTimer); + } + if (currentCount >= 2) { + setEClickedCount(0); + void openFileExplorerFromShortcut(); + } else { + eTimer = setTimeout(() => { + setEClickedCount(0); + }, 700); + } + }, + }, + ], + })); + return (