Add hotkeys manager

- Add configuration to settings store
- Initialize global hotkeys on startup from renderer
This commit is contained in:
jeffvli 2023-05-13 00:58:32 -07:00 committed by Jeff
parent 6056504f00
commit d7f24262fd
7 changed files with 432 additions and 12 deletions

View file

@ -29,3 +29,24 @@ export const isWindows = () => {
export const isLinux = () => {
return process.platform === 'linux';
};
export const hotkeyToElectronAccelerator = (hotkey: string) => {
let accelerator = hotkey;
const replacements = {
mod: 'CmdOrCtrl',
numpad: 'num',
numpadadd: 'numadd',
numpaddecimal: 'numdec',
numpaddivide: 'numdiv',
numpadenter: 'numenter',
numpadmultiply: 'nummult',
numpadsubtract: 'numsub',
};
Object.keys(replacements).forEach((key) => {
accelerator = accelerator.replace(key, replacements[key as keyof typeof replacements]);
});
return accelerator;
};