Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable default keybindings? #287

Closed
akosyakov opened this issue Dec 7, 2016 · 9 comments
Closed

How to disable default keybindings? #287

akosyakov opened this issue Dec 7, 2016 · 9 comments
Labels
editor-api feature-request Request for new features or functionality
Milestone

Comments

@akosyakov
Copy link

No description provided.

@rebornix rebornix added editor-api feature-request Request for new features or functionality labels Jul 13, 2017
@rebornix
Copy link
Member

from @dengkunli

I read through the API doc (monaco.d.ts) but cannot find a way to disable predefined shortcuts shipped with Monaco. Am I missing something ? How can we disable a shortcut (for example ctrl/cmd + e) ?

If there's no interface for disabling shortcut currently, will it be supported in the near future ? Having no such interface makes the editor much less customizable.

@rebornix rebornix added this to the Backlog milestone Jul 13, 2017
@oldrich-s
Copy link

Any news on that? I would like to disable ctrl+F keybinding and give it back to browser ;)

@ledbit
Copy link

ledbit commented Sep 10, 2017

Not sure about how to give the functionality back to the browser, but I found that you can disable the ctrl+F binding by adding your own noop one, as follows:

editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_F, function() {});

@vlad-shatskyi
Copy link

vlad-shatskyi commented Sep 22, 2017

A workaround to unbind default keybindings using a private API:

editor._standaloneKeybindingService.addDynamicKeybinding("-editor.action.outdentLines");

Replace "editor.action.outdentLines" with the action you want to unbind. Unlike the @ledbit's solution, it doesn't prevent the event from bubbling up.

@oldrich-s
Copy link

@vlad-shatskyi : Thanks 👍 editor._standaloneKeybindingService.addDynamicKeybinding("-actions.find") did the job

@roboslone
Copy link

It doesn't seem to work with Ctrl/Cmd+L:

Object.keys(editor._actions).forEach(
    k => {
        editor._standaloneKeybindingService.addDynamicKeybinding(`-${k}`)
    }
)

After this magic some keybindings are gone (Cmd+F doesn't work, for example), but Cmd+L still expands selection to a next line.

@donaldpipowitch
Copy link

@roblourens , did you ever found a solution for Cmd+L?

@jessermejia
Copy link

to unbind Cmd+L try this:

editor._standaloneKeybindingService.addDynamicKeybinding('-expandLineSelection');

i determined which command to unbind by seeing that this method returned true. for Cmd+L, the resolveResult found something here

fwiw, the default keybindings can (currently) be listed like this:

editor._standaloneKeybindingService._getResolver()._defaultKeybindings

expandLineSelection gets registered when pulling in coreCommands here.

@alexdima
Copy link
Member

Let's track in #102

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-api feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

9 participants