Problem
There's an inconsistency in how modifier keys are validated between the following files which makes it impossible to use Meta/Super as an accelerator on Linux:
/packages/lib/services/KeymapService.ts
/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/utils/useKeymap.ts
KeymapService.ts
defines valid modifiers as Ctrl, Alt, AltGr, Shift, Super (note the absence of Meta)
9 const modifiersRegExp = {
10 darwin: /^(Ctrl|Option|Shift|Cmd)$/,
11 default: /^(Ctrl|Alt|AltGr|Shift|Super)$/,
12 };
whereas normalizeAccelerator()
in useKeymap.ts
accepts cmd, meta, m, but NOT Super:
50 if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; } else if (/^a(lt)?$/i.test(mod)) { alt = true; } else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; } else if (/^s(hift)?$/i.test(mod)) { shift = true; } else { throw new Error(`Unrecognized modifier name: ${mod}`); }
I am unable to set the Meta/Super key as a modifier when trying to enter a keyboard shortcut through the GUI (the modifier just seems to be ignored), but I can define an accelerator to use Super in a json file and import it, for example:
[
{
"command": "newNote",
"accelerator": "Super+N"
},
{
"command": "quit",
"accelerator": "Super+Q"
},
...
]
This passes validation on import. However, the application will throw an exception as soon as the codepath through normalizeAccelerator
in useKeymap.ts
is followed (which happens for me as soon as I open a note).
And, as expected, if I try to replace Super with Meta in the json file, it will fail validation and throw an error in KeymapService.ts (line 327) and fail to import.
Regardless, I've found that shortcuts imported from a file do not get set properly and do not persist across application launches, even when fully valid key combinations are used, so there may be more to this problem in other parts of the code beyond what I've outlined here.
In the above json import example, the quit
shortcut will be successfully set, but the newFile
shortcut will not (it will appear to be set in the list of keyboard shortcuts in the Options panel, but will not be reflected in the menus). And both will be reset to their default values when relaunching the application. This happens even if I specify other modifier keys besides Super (e.g. Shift, Ctrl, or Alt).