While currently there are no keyboard shortcuts that are limited to just one context, I agree that it'll be a useful improvement in the future. I can imagine some use cases for such feature. Maybe shortcuts that are limited to just the note list, or the notebook list, or some shortcuts specific to WYSIWYG or just one editor.
Just checking if shortcuts are unique isn't enough in this case. It would be useful to reuse the keyboard shortcut that is only available in the note list, somewhere else in the application. I think we can fix this by checking if the shortcuts are unique within their own context.
I suggest the following data structure for the shortcuts:
{ accelerator: 'Control+N', command: 'newNoteItem', context: 'default' }
Using this structure, we can specify a shortcut limited to note list: select all menu as following:
{ accelerator: 'Control+Shift+M', command: 'moveToNotebook', context: 'noteListSelectAll' }
If something like this is implemented in the future, while it is a different context than default
, keyboard shortcuts in the default
context should still be enabled. (Just my opinion) Otherwise user has to "exit" the current context to use their familiar shortcuts. Shortcuts of default
context are, quote, unquote, "Global shortcuts" throughout the application.
We should be able to reuse the above shortcut in some other context:
(Let's just assume this shortcut is only available if you're focused in the sidebar, and nowhere else)
{ accelerator: 'Control+Shift+M', command: 'newNotebook', context: 'sidebar' }
In conclusion, a shortcut is duplicate if:
- Context is
default
, and it's already used - Context is not
default
, but it's already used in default context
It's not a duplicate if:
- Context is
default
, and it's not already used - Context is not
default
, and it's not used in default context (but maybe in some other context)
Moved conversation:
The issue is to whether we should allow two different shortcuts for two different actions, and disambiguate based on the context? If that’s the question then yes that should be allowed.
But on the other hand there’s no context column in the mockup so I’m not sure what’s the status of it? I guess it’s whatever is logical: if the primary key is the shortcut, then there can’t be twice the same shortcut. If the primary key is shortcut/context then there can be twice the same shortcut.
I think we should go with unique shortcuts for each action, mainly because Joplin doesn’t have a lot of shortcuts. Another benefit is the user don’t have to change the focus beforehand executing a keyboard shortcut.
As I was saying, currently all shortcuts are enabled when the user is editing the note body. That’s why I didn’t include a context field in the mock-ups. (Even if I did, then it’d be “Default” for everything…) Therefore having context-limited shortcuts are not useful at the moment, in my humble opinion.
I agree it’s not currently useful but it feels like the kind of thing that would be hard to add back later on, while it’s relatively easy now. But maybe I’m missing something.
What would be useful is to see your current data structure for the shortcuts, actions, etc. as that would inform what we can support or not. In fact, you should maybe have a separate post for this where you keep it up-to-date based on your discussions with Tessus and me?