Hello,
I am developing a plugin that has text entry similar to chat and I wanted the user to be able to configure the hotkeys used to SEND and NEWLINE separately. Originally I had these settings in my own plugin settings, but it was pointed out that it made more sense as a platform for them to be in the global Hotkeys. This way users could see conflicts.
However it appears to not be possible to bind “enter” to a hotkey. Of course I can see why this might be, as a global hotkey for “Enter” would probably be bad, but in my case this hotkey has a defined scope.
Obviously I can go back to configuring this locally in my own plugin, but the point about hotkeys living with other hotkeys is a valid one, so I wanted to inquire about this behaviour.
Thanks you!
Hotkeys can’t have conflicting keybinds (for example, two hotkeys that both are invoked with CtrlT), even if they have different scopes. Because a “scope” from a command/hotkey is defined by a developer and can be any arbitrary JS, there’s no way to guarantee that two commands couldn’t be triggered at the same time. Especially common keybinds (such as Enter) are therefore not suitable for hotkeys, since they need to be used in lots of scopes.
Seems like a better use case for Scope.register? It’ll allow you to conditionally enable Enter as a keybind within your scope.
The problem isn’t using the keys, it’s surfacing them for the user. Having them select keybindings in the plugin settings feels wrong to me, and will probably be frowned upon if I ever submit it for the community plugins, but I don’t really have a choice either.