Fix shortcut capture ignoring - = ; ' keys (#2047)

* Fix shortcut capture ignoring - = ; ' keys

KEY_MAP was missing Minus/Equal/Semicolon/Quote, so
keyboardEventToComboString returned null for those physical keys and
the capture UI silently dropped them. Add the four entries with their
shifted variants.

Also suppress the Electron View > Zoom accelerators (Cmd+-/=/0) while
capturing, so those combos reach the renderer instead of zooming the
window. Driven by the existing capturingShortcut flag via a new
paseo:menu:set-capturing-shortcut IPC.

* fix: address review feedback from PR #2047

Trim the capturing useEffect so it only fires when capture is active
(removes the redundant on-mount false and the double-fire on true->false),
and reset the main-process capturingShortcut flag on renderer reload via
browser-window-created + did-finish-load so a Cmd+R mid-capture can't
leave the zoom accelerators disabled.

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
OnCloud
2026-07-14 13:30:32 +02:00
committed by GitHub
co-authored by Mohamed Boudra
parent 9ea58aae0c
commit c0b801b805
6 changed files with 127 additions and 2 deletions
+37 -2
View File
@@ -47,8 +47,10 @@ function reloadFocusedContentsOrWindow(win: BrowserWindow, options?: { ignoreCac
function buildApplicationMenuTemplate(
options: ApplicationMenuOptions,
capturing: boolean,
): Electron.MenuItemConstructorOptions[] {
const isMac = process.platform === "darwin";
const zoomEnabled = !capturing;
return [
...(isMac
@@ -99,6 +101,7 @@ function buildApplicationMenuTemplate(
{
label: "Zoom In",
accelerator: "CmdOrCtrl+=",
enabled: zoomEnabled,
click: withBrowserWindow((win) => {
win.webContents.setZoomLevel(win.webContents.getZoomLevel() + 0.5);
}),
@@ -106,6 +109,7 @@ function buildApplicationMenuTemplate(
{
label: "Zoom Out",
accelerator: "CmdOrCtrl+-",
enabled: zoomEnabled,
click: withBrowserWindow((win) => {
win.webContents.setZoomLevel(win.webContents.getZoomLevel() - 0.5);
}),
@@ -113,6 +117,7 @@ function buildApplicationMenuTemplate(
{
label: "Actual Size",
accelerator: "CmdOrCtrl+0",
enabled: zoomEnabled,
click: withBrowserWindow((win) => {
win.webContents.setZoomLevel(0);
}),
@@ -150,9 +155,20 @@ function buildApplicationMenuTemplate(
];
}
export function setupApplicationMenu(options: ApplicationMenuOptions): void {
const menu = Menu.buildFromTemplate(buildApplicationMenuTemplate(options));
let applicationMenuOptions: ApplicationMenuOptions | null = null;
let capturingShortcut = false;
function rebuildApplicationMenu(): void {
if (!applicationMenuOptions) return;
const menu = Menu.buildFromTemplate(
buildApplicationMenuTemplate(applicationMenuOptions, capturingShortcut),
);
Menu.setApplicationMenu(menu);
}
export function setupApplicationMenu(options: ApplicationMenuOptions): void {
applicationMenuOptions = options;
rebuildApplicationMenu();
ipcMain.handle("paseo:menu:showContextMenu", (event, input?: ShowContextMenuInput) => {
const win = BrowserWindow.fromWebContents(event.sender);
@@ -185,4 +201,23 @@ export function setupApplicationMenu(options: ApplicationMenuOptions): void {
contextMenu.popup({ window: win });
});
// Disable the zoom accelerators while capturing a shortcut so combos like
// Cmd+- / Cmd+= reach the renderer instead of zooming the window.
ipcMain.handle("paseo:menu:set-capturing-shortcut", (_event, capturing?: boolean) => {
capturingShortcut = capturing === true;
rebuildApplicationMenu();
});
// If the renderer reloads mid-capture (e.g. Cmd+R) the renderer-side effect
// never gets to send `false`, so reset the flag from the main process when a
// main window finishes loading. Workspace browser webviews are not
// BrowserWindows, so they don't trigger this.
app.on("browser-window-created", (_event, win) => {
win.webContents.on("did-finish-load", () => {
if (!capturingShortcut) return;
capturingShortcut = false;
rebuildApplicationMenu();
});
});
}
+2
View File
@@ -72,6 +72,8 @@ contextBridge.exposeInMainWorld("paseoDesktop", {
menu: {
showContextMenu: (input?: Record<string, unknown>) =>
ipcRenderer.invoke("paseo:menu:showContextMenu", input),
setCapturingShortcut: (capturing: boolean) =>
ipcRenderer.invoke("paseo:menu:set-capturing-shortcut", capturing),
},
browser: {
registerWorkspaceBrowser: (input: { browserId: string; workspaceId: string }) =>