Search code examples
monaco-editor

monaco-editor: how to trigger backspace


I want to emulate keyboard event. but the code:

editor.trigger(monaco.KeyCode.Backspace, 'type')

not work,

it will not delete current char in editor.


Solution

  • For Backspace key monaco has specific core command called deleteLeft:

    editor.trigger(monaco.KeyCode.Backspace, 'deleteLeft')