Bug: Inconsistent modifier key validation renders Meta/Super unusable in keyboard shortcuts on Linux

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).

The same happens here.

Garuda/Arch Gnome 43.2
Joplin 2.9.17 (prod, linux)
Client ID: [redacted]
Sync Version: 3
Profile Version: 41
Keychain Supported: No
Revision: a84a8e7

I'll eventually file a proper issue on the repo for this but I won't have an opportunity another week or two, so I at least wanted to bring attention to this and start the discussion here, providing as much detail as I could.

This should probably end up as 2 issues, if not 3:

  • keyboard shortcuts failing to import properly from json file and being reverted on app restart
  • inconsistent handling of meta/super in different parts of the code base
  • meta/super key not being registered when setting a keyboard shortcut through the GUI (not sure if this is separate from the 2nd issue or not)

Anyway, here is about info from my joplin instance:

Joplin 2.9.17 (prod, linux)

Client ID: ***
Sync Version: 3
Profile Version: 41
Keychain Supported: No

Revision: a84a8e7

1 Like