Skip to content

Commit

Permalink
Disable keyboard naviation for Mac completely
Browse files Browse the repository at this point in the history
The previous attempt to use Command (Meta) + Left / Right did not work.
  • Loading branch information
jstastny committed Feb 13, 2024
1 parent 309518c commit 1f53fb1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/browser/tools/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ 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(),
[`${navigationModifiedKey}_ArrowLeft`]: () => window.history.back(),
[`${navigationModifiedKey}_ArrowRight`]: () => window.history.forward()
// Alt (Option) Left / Right is used to jump words in Mac, so diabling the history navigation for Mac here
...(!isMac ?
{
'ALT_ArrowLeft': () => window.history.back(),
'ALT_ArrowRight': () => window.history.forward()
}
: {}
)
};

function initInternal() {
Expand Down Expand Up @@ -92,7 +97,7 @@ function wheelEventHandler(event) {
}

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

function fireEvent(event, keyName) {
Expand Down

0 comments on commit 1f53fb1

Please sign in to comment.