I'm using a different textfield as a proxy for CodeMirror. I want to use features such as closebrackets.js
which are activated via keyboard events such as keydown
, keypress
, and keyup
. I've tried several different approaches to trigger these events, none of which have caused CodeMirror to receive anything:
kc = 219
e = $.Event 'keydown', { which: kc }
$( myCodeMirror.getInputField() ).trigger e
Doesn't work. No events are fired.
cmIF = $( myCodeMirror.getInputField() )
textArea = $('<textarea></textArea>')
$('body').append textArea
textArea.keydown (e) ->
cmIF.focus()
return
kc = 219
e = $.Event 'keydown', { which: kc }
textArea.trigger e
Trying to forward events from a different text area. Doesn't work. CM doesn't events don't get triggered.
$( myCodeMirror.getWrapperElement() ).children().each (index) ->
$(this).trigger e
return
Trying to trigger the event on every child of CMs wrapper. Doesn't work. No CM events fired.
What am I doing wrong here? How can I trigger keyboard events on a CodeMirror instance?