Joplin desktop application supports keyboard shortcuts to a certain degree. However, there wasn't an option for users to configure keyboard shortcuts according to their preferences. My project was to implement a keyboard shortcut editor along with the necessary integration.
The project consisted of two parts:
- Back-end service for handling all keymapping-related functionality
- Keyboard shortcut editor with the necessary functionality to alter the keymap
The project was implemented in two pull requests.
KeymapService builds an in-memory keymap based on the default keymap configuration. Default keymap configuration may vary from platform to platform. Essentially, the in-memory keymap binds a keyboard shortcut for some command of Joplin. Clients of KeymapService may obtain the keyboard shortcuts for some commands, and/or alter the keymap via the provided methods.
Additionally, this PR also allows altering the keymap via a keymap file, which is located in the profile directory. Contents of this keymap file will take higher priority than the default keymap configuration, and will replace the default keyboard shortcuts.
It is guaranteed that the keymap always stays pristine with proper validation.
Depending on the interfaces of KeymapService, Keyboard shortcut editor allows the user to,
- View all the available commands and their respective keyboard shortcuts
- Change, or disable a keyboard shortcut for some command
- Restore a keyboard shortcut to its default value
- Export all changes to a keymap file (in JSON format)
- Import changes from an exported keymap file
- Perform a simple search to locate some shortcut
Changes performed to the keymap will be reflected immediately in the keymap file located in the profile directory. The editor will also perform continuous validation to ensure that the keymap will not enter a dirty-state.
This PR also includes a lot of improvements to KeymapService to support these additional functions.