@@ -14,6 +14,26 @@ type RegistryEntry = {
1414// Global registry for key handlers
1515const registry : Set < RegistryEntry > = new Set ( ) ;
1616
17+ // Callback to navigate to home (registered by MainLayout)
18+ let goHomeCallback : ( ( ) => void ) | null = null ;
19+
20+ /**
21+ * Register a callback to navigate to home (used for Ctrl+C in certain views)
22+ */
23+ export function registerGoHomeCallback ( callback : ( ) => void ) : void {
24+ goHomeCallback = callback ;
25+ }
26+
27+ /**
28+ * Function to set the current view for Ctrl+C handling
29+ * This should be called by the app to track which view we're in
30+ */
31+ let currentView : string = 'home' ;
32+
33+ export function setCurrentViewForCtrlC ( view : string ) : void {
34+ currentView = view ;
35+ }
36+
1737/**
1838 * Hook to bind keyboard shortcuts.
1939 * This uses a centralized manager to avoid multiple useInput calls and memory leaks.
@@ -88,6 +108,20 @@ export function KeyboardManager() {
88108 if ( blockCount > 0 ) {
89109 // When keyboard input is blocked (e.g., within a focused text input),
90110 // check if any entry has bypassBlock flag and matches this key.
111+ // First check for Ctrl+C special case - go to home in search view
112+ if ( key . ctrl && input === 'c' ) {
113+ if ( currentView === 'search' ) {
114+ if ( goHomeCallback ) {
115+ goHomeCallback ( ) ;
116+ }
117+
118+ return ;
119+ }
120+
121+ // In other views, quit the app
122+ process . exit ( 0 ) ;
123+ }
124+
91125 for ( const entry of registry ) {
92126 if ( entry . bypassBlock ) {
93127 for ( const binding of entry . keys ) {
@@ -173,11 +207,6 @@ export function KeyboardManager() {
173207 } ) ;
174208 }
175209
176- // Global quit handling
177- if ( key . ctrl && input === 'c' ) {
178- process . exit ( 0 ) ;
179- }
180-
181210 // Dispatch to registered handlers
182211 for ( const entry of registry ) {
183212 const { keys, handler} = entry ;
0 commit comments