How to programmaticaly get the key-binding for a command in a keymap file?


#1

I am currently binding the escape key to toggle a modal dialog dialog that appears in my package. This is just another way for the user to say “close the box” instead of typing “shift-ctrl-v” again (which is how they bring it up).

Here is the portion of my keymap.cson:

“.local-theme-selector-view”:
“escape”: “local-theme-selector-view:multiThemeApplicatorToggle”

I’m using esc because it’s sort of the default “get out of jail key” for most people. The default for esc is ‘cancel:core’. But what if the user has bound their "get out of jail " keybinding to something else, say “ctrl-g” (as it is with emacs keybindings). Then they would expect to hit “ctrl-g” as the “get out” key.

I would rather specify something like:

“.local-theme-selector-view”:
keyBinding(‘cancel:core’): “local-theme-selector-view:multiThemeApplicatorToggle”

And then the keybinding would “float” to whatever keybinding the user uses, instead of me hard-coding it as “esc”.

Is there a way to do this?

Thanks.


#2

Have you taken a look at the API documentation?