Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions apps/desktop/electron/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2930,23 +2930,27 @@ function installPreviewShortcut(window) {

function installZoomShortcuts(window) {
// Override Ctrl/Cmd + +/-/0 with half the default zoom step (0.1 vs 0.2).
// The menu items handle this on macOS (where the menu is always present),
// but on Linux/Windows the menu is null and Chromium's default handler
// would use the full 0.2 step, so we intercept here for consistency.
// On Japanese/JIS keyboards, typing "+" normally includes Shift, and Electron
// may surface the physical key as "+", "=", ";", or ":" depending on layout.
// Do not reject Shift globally; only require it to be absent for reset/zoom-out.
const ZOOM_STEP = 0.1
window.webContents.on('before-input-event', (event, input) => {
const mod = IS_MAC ? input.meta : input.control
if (!mod || input.alt || input.shift) return
if (!mod || input.alt) return

const key = input.key
if (key === '0') {
const key = String(input.key || '')
const isZoomReset = key === '0' && !input.shift

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main no longer tracks main.cjs: commit 39d09453f renamed it to apps/desktop/electron/main.ts. Please port this predicate to the current installZoomShortcuts handler there, preserving its setAndPersistZoomLevel calls.

const isZoomIn = key === '=' || key === '+' || key === 'Add' || (input.shift && (key === ';' || key === ':'))
const isZoomOut = key === '-' && !input.shift

if (isZoomReset) {
event.preventDefault()
window.webContents.setZoomLevel(0)
} else if (key === '=' || key === '+') {
} else if (isZoomIn) {
event.preventDefault()
const next = Math.min(window.webContents.getZoomLevel() + ZOOM_STEP, 9)
window.webContents.setZoomLevel(next)
} else if (key === '-') {
} else if (isZoomOut) {
event.preventDefault()
const next = Math.max(window.webContents.getZoomLevel() - ZOOM_STEP, -9)
window.webContents.setZoomLevel(next)
Expand Down