Search code examples
javascriptcodemirrorkey-events

codemirror search simulate CTRL+F keys with javascript


I'm trying to open the codemirror search dialog (normally activated by pressing CTRL+F)
by pressing a button:

I tried to use

window.find()

but it does not open the dialog, it only highlights the text in the editor...

DEMO


Solution

  • You don't want to simulate the actual key press. Rather, simply run CodeMirror's find command using execCommand, as in http://jsfiddle.net/cb1fd72k/1/