Komodo Edit/IDE Macro to Change Keyboard Shortcut

Is there a way to write a Macro to change a keyboard shortcut?

I know that this will involve possibly duplicating a Key Binding scheme, so I would also appreciate information on testing whether a particular named scheme exists, how to create one, and how to select it.

Is that something available in the API?

You’re looking for require(“ko/keybindings”);. That should have what you’re looking for @manngo.

  • Carey

Thanks for the link. I has most of what I need, but I can’t see how to change the current configuration (there is no setCurrentConfig()) or to create one. Is that possible?

Doesn’t look like that stuff made it into the new SDK. You can find that in the legacy stuff though.

You’ll likely want to use ko.keybindings.manager.makeNewConfiguration(name, prefs) to make a new keybinding set. Note that this copies the current keybinding set and names it name.

Then use ko.keybindings.manager.switchConfiguration(name). That ones straight forward.

Example:

ko.keybindings.manager.makeNewConfiguration("pizza",require("ko/prefs"));
ko.keybindings.manager.switchConfiguration("pizza");

You can use View > Tabs & Sidebars > Console to quickly try that out.

  • Carey

Following your links, I’ve added the following to the beginning of your sample code:

if(!ko.keybindings.manager._configKnown('pizza'))

and it works perfectlly.

Thanks for your help.

1 Like