✨ Close the window with Ctrl+W
Consent
- I verified that there is no open/closed issue for the same subject.
- I understand that YTMDesktop have NO affiliation with Google or YouTube
Feature
Ctrl+W (Cmd+W on macOS) should close the window, the way it does in a browser and in most desktop apps. Today it does nothing — Alt+F4 and the titlebar X button are the only ways to close.
Solution
There is no window-scoped keyboard handling in the app at the moment, so there is nothing for the key to hook into:
before-input-eventis not used anywhere.- No local-shortcut library is a dependency.
- The application menu is deliberately set to
nullon Windows and Linux for performance, so there are no menu accelerators to inherit. The macOSappMenu/editMenuroles provide Cmd+Q and the edit shortcuts, but norole: "close". globalShortcutis used, but only for the configurable media keys.
globalShortcut would be the wrong tool here: it is system-wide, so binding Ctrl+W there would swallow the shortcut from every other application while YTMDesktop is running. A before-input-event listener on the window's webContents is the right scope.
One detail worth flagging for anyone implementing it: the YouTube Music page lives in a BrowserView with its own webContents, and that is where focus sits nearly all of the time — the main window's own webContents is just the 36px titlebar. A listener registered only on the main window would appear to do nothing in normal use. The settings window is a separate modal BrowserWindow and needs its own registration that closes itself rather than the parent behind it.
Alternatives
- Adding a
role: "close"menu item — only works on macOS, since the menu isnullelsewhere. - Making it a user-configurable shortcut in Settings — Ctrl+W is conventional enough to hard-code, and configurability would mean extending the shortcuts schema, the settings UI, and the registration-conflict reporting.
Anything else?
A PR is up in #1800. While implementing it I ran into a related defect where the close paths disagree with each other, filed separately as #1801; the same PR fixes both, since both come down to routing every close path through one handler.
Source: ytmdesktop/ytmdesktop