Skip to content

Commit

Permalink
Navigation on Mac with Command instead of Option
Browse files Browse the repository at this point in the history
  • Loading branch information
jstastny committed Feb 13, 2024
1 parent dd2fe2f commit 309518c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/browser/tools/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ class Shortcuts {
}
}

const isMac = os.platform() === 'darwin';
const navigationModifiedKey = isMac ? 'META' : 'ALT';

const KEY_MAPS = {
'CTRL_+': () => zoom.increaseZoomLevel(),
'CTRL_=': () => zoom.increaseZoomLevel(),
'CTRL_-': () => zoom.decreaseZoomLevel(),
'CTRL__': () => zoom.decreaseZoomLevel(),
'CTRL_0': () => zoom.resetZoomLevel(),
'ALT_ArrowLeft': () => window.history.back(),
'ALT_ArrowRight': () => window.history.forward()
[`${navigationModifiedKey}_ArrowLeft`]: () => window.history.back(),
[`${navigationModifiedKey}_ArrowRight`]: () => window.history.forward()
};

function initInternal() {
Expand Down Expand Up @@ -70,7 +73,7 @@ function whenIframeReady(callback) {

function keyDownEventHandler(event) {
const keyName = event.key;
if (keyName === 'Control' || keyName === 'Alt') {
if (keyName === 'Control' || keyName === 'Alt' || keyName === 'Meta') {
return;
}

Expand All @@ -89,7 +92,7 @@ function wheelEventHandler(event) {
}

function getKeyName(event, keyName) {
return `${event.ctrlKey ? 'CTRL_' : ''}${event.altKey ? 'ALT_' : ''}${keyName}`;
return `${event.ctrlKey ? 'CTRL_' : ''}${event.altKey ? 'ALT_' : ''}${event.metaKey ? 'META_': ''}${keyName}`;
}

function fireEvent(event, keyName) {
Expand Down

0 comments on commit 309518c

Please sign in to comment.