From a511dae28450e160299b34129954af12173d7ff6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= <mordae@anilinux.org>
Date: Sun, 9 Mar 2025 10:01:33 +0100
Subject: [PATCH] Add key press handler to main menu

---
 lazy_player/__init__.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lazy_player/__init__.py b/lazy_player/__init__.py
index a9e6ba9..dc21a23 100644
--- a/lazy_player/__init__.py
+++ b/lazy_player/__init__.py
@@ -314,6 +314,18 @@ class MainWindow(Gtk.ApplicationWindow):
 
         return False
 
+    def _on_menu_key_pressed(
+        self,
+        keyval: int,
+        keycode: int,
+        state: Gdk.ModifierType,
+    ) -> bool:
+        if keyval == Gdk.keyval_from_name("q"):
+            self.close()
+            return True
+
+        return False
+
     def _on_key_pressed(
         self,
         controller: Gtk.EventControllerKey,
@@ -321,10 +333,11 @@ class MainWindow(Gtk.ApplicationWindow):
         keycode: int,
         state: Gdk.ModifierType,
     ) -> bool:
-        # If we're showing video, handle keys differently
+        # Handle keys differently based on which view is active
         if self.stack.get_visible_child_name() == "overlay":
             return self._on_video_key_pressed(keyval, keycode, state)
-        return False
+        else:
+            return self._on_menu_key_pressed(keyval, keycode, state)
 
     def _seek_relative(self, offset: int) -> None:
         """Seek relative to current position by offset seconds"""