Skip to content

How to send ESC from js script to switch to VIM normal mode? #5463

Closed Answered by jonasermert
kkarsten62 asked this question in Q&A
Discussion options

You must be logged in to vote
var editor = ace.edit("your-editor-id"); // replace 'your-editor-id' with the actual ID of your Ace editor instance

// Switch to normal mode programmatically
var event = new KeyboardEvent('keypress', {
  keyCode: 27,  // Key code for ESC key
  which: 27     // Additional property for some browsers
});

editor.textInput.getElement().dispatchEvent(event);

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kkarsten62
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants