Skip to content

Commit 0b63064

Browse files
ankitmarijnh
authored andcommitted
Pass 'keyup' event to onKeyEvent handler
1 parent ee6b56d commit 0b63064

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lib/codemirror.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ var CodeMirror = (function() {
325325
fastPoll(curKeyId);
326326
}
327327
function onKeyUp(e) {
328+
if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e.e))) return;
328329
if (reducedSelection) {
329330
reducedSelection = null;
330331
updateInput = true;

manual.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,21 @@ <h2 id="config">Configuration</h2>
252252
<dt id="option_onKeyEvent"><code>onKeyEvent (function)</code></dt>
253253
<dd>This provides a rather low-level hook into CodeMirror's key
254254
handling. If provided, this function will be called on
255-
every <code>keydown</code> and <code>keypress</code> event that
256-
CodeMirror captures. It will be passed two arguments, the editor
257-
instance and the key event. This key event is pretty much the
258-
raw key event, except that a <code>stop()</code> method is
259-
always added to it. You could feed it to, for
260-
example, <code>jQuery.Event</code> to further normalize
261-
it.<br>This function can inspect the key event, and handle it if
262-
it wants to. It may return true to tell CodeMirror to ignore the
263-
event. Be wary that, on some browsers, stopping
264-
a <code>keydown</code> does not stop the <code>keypress</code>
265-
from firing, whereas on others it does. If you respond to an
266-
event, you should probably inspect its <code>type</code>
267-
property and only do something when it is <code>keydown</code>
268-
(or <code>keypress</code> for actions that need character
269-
data).</dd>
255+
every <code>keydown</code>, <code>keyup</code>,
256+
and <code>keypress</code> event that CodeMirror captures. It
257+
will be passed two arguments, the editor instance and the key
258+
event. This key event is pretty much the raw key event, except
259+
that a <code>stop()</code> method is always added to it. You
260+
could feed it to, for example, <code>jQuery.Event</code> to
261+
further normalize it.<br>This function can inspect the key
262+
event, and handle it if it wants to. It may return true to tell
263+
CodeMirror to ignore the event. Be wary that, on some browsers,
264+
stopping a <code>keydown</code> does not stop
265+
the <code>keypress</code> from firing, whereas on others it
266+
does. If you respond to an event, you should probably inspect
267+
its <code>type</code> property and only do something when it
268+
is <code>keydown</code> (or <code>keypress</code> for actions
269+
that need character data).</dd>
270270
</dl>
271271

272272
<h2 id="styling">Customized Styling</h2>

0 commit comments

Comments
 (0)