Permalink
Browse files

Expose triggerOnKeyPress and triggerOnKeyUp for testing

  • Loading branch information...
1 parent 31a264a commit a0522c12766735a033a9b7aeed21bce2922dcded @aslushnikov aslushnikov committed with marijnh Jan 23, 2014
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/codemirror.js
View
@@ -1629,10 +1629,7 @@ window.CodeMirror = (function() {
}
setTimeout(unregister, 5000);
- on(d.input, "keyup", operation(cm, function(e) {
- if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
- if (e.keyCode == 16) cm.doc.sel.shift = false;
- }));
+ on(d.input, "keyup", operation(cm, onKeyUp));
on(d.input, "input", function() {
if (ie && !ie_lt9 && cm.display.inputHasSelection) cm.display.inputHasSelection = null;
fastPoll(cm);
@@ -2142,6 +2139,12 @@ window.CodeMirror = (function() {
return handled;
}
+ function onKeyUp(e) {
+ var cm = this;
+ if (signalDOMEvent(cm, e) || cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
+ if (e.keyCode == 16) cm.doc.sel.shift = false;
+ }
+
var lastStoppedKey = null;
function onKeyDown(e) {
var cm = this;
@@ -3157,6 +3160,8 @@ window.CodeMirror = (function() {
},
triggerOnKeyDown: operation(null, onKeyDown),
+ triggerOnKeyPress: operation(null, onKeyPress),
+ triggerOnKeyUp: operation(null, onKeyUp),
execCommand: function(cmd) {
if (commands.hasOwnProperty(cmd))

0 comments on commit a0522c1

Please sign in to comment.