Skip to content

Commit

Permalink
shortcut: Allow zoom options from numpad.
Browse files Browse the repository at this point in the history
Numpad keys by default aren't supported by electron
for using in menu accelarators. Uses a workaround to
make zoom options work with Numpad keys.

Fixes: #344.
  • Loading branch information
vsvipul authored and akashnimare committed Apr 12, 2019
1 parent 88c64e9 commit 6e76097
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/renderer/js/preload.js
Expand Up @@ -91,8 +91,15 @@ window.addEventListener('beforeunload', () => {

// electron's globalShortcut can cause unexpected results
// so adding the reload shortcut in the old-school way
// Zoom from numpad keys is not supported by electron, so adding it through listeners.
document.addEventListener('keydown', event => {
if (event.code === 'F5') {
ipcRenderer.send('forward-message', 'hard-reload');
} else if (event.ctrlKey && event.code === 'NumpadAdd') {
ipcRenderer.send('forward-message', 'zoomIn');
} else if (event.ctrlKey && event.code === 'NumpadSubtract') {
ipcRenderer.send('forward-message', 'zoomOut');
} else if (event.ctrlKey && event.code === 'Numpad0') {
ipcRenderer.send('forward-message', 'zoomActualSize');
}
});

0 comments on commit 6e76097

Please sign in to comment.