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 efeef6c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 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 @@ -73,7 +78,7 @@ function whenIframeReady(callback) {

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

Expand All @@ -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 efeef6c

Please sign in to comment.