Monaco-editor: How can I change triggerSuggest hot key from Ctrl+Space to another key?

Created on 10 Jan 2018  路  5Comments  路  Source: microsoft/monaco-editor


monaco-editor version: 0.10.1
Browser: Chrome
OS: Windows
Steps or JS usage snippet reproducing the issue:

How can I change triggerSuggest hot key from Ctrl+Space to another key?

Because Ctrl + Space is hot key for Switch Input Method in Chinese Windows.

But I can't find how to change to another. How can I do this?

feature-request

All 5 comments

    $(document).on('keydown', function () {
        var oEvent = window.event;
        if (oEvent.keyCode == 13 && oEvent.altKey) {
            triggerSuggest();
        }
    });

    function triggerSuggest() {
        monacoEditor.trigger('', 'editor.action.triggerSuggest', {});
    }

You can use (change the e.code to whatever you want)

editor.onKeyDown((e) => {
      if (e.code === 'Space' && e.ctrlKey === true) {
        console.log('YES ! ');
      }
    });

We're currently not exposing the IKeybindingService which would allow for customization of keyboard shortcuts...

editor.addCommand(monaco.KeyCode.Tab,
        () => {
          editor.trigger('', 'editor.action.triggerSuggest', '');
        },
        'editorTextFocus && !editorHasSelection && ' +
        '!editorHasMultipleSelections && !editorTabMovesFocus && ' +
        '!hasQuickSuggest');

Let's track in #102

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabiospampinato picture fabiospampinato  路  3Comments

Kang-Jun-sik picture Kang-Jun-sik  路  3Comments

galyech picture galyech  路  3Comments

Kedyn picture Kedyn  路  3Comments

Spongman picture Spongman  路  3Comments