diff --git a/demos/playground/playground.js b/demos/playground/playground.js index 5d57514489..78841900df 100644 --- a/demos/playground/playground.js +++ b/demos/playground/playground.js @@ -32,9 +32,9 @@ app = function () { this.$editor.html("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."); this.$editor.addClass('leafNode'); - this.keypress = false; - this.keyup = false; this.keydown = false; + this.keyup = false; + this.keypress = false; this.mousedown = false; this.inime = false; this.prevText = app.getDOMText(this.$editor[0]); @@ -44,7 +44,23 @@ app = function () { }, 100); }; -app.prototype.onKeyPress = function() { +app.prototype.onKeyDown = function( e ) { + console.log("onKeyDown"); + this.keydown = true; + if ( e.which === 229 ) { + this.inime = true; + } +}; + +app.prototype.onKeyUp = function( e ) { + console.log("onKeyUp"); + this.keyup = true; + if ( this.inime ) { + this.inime = false; + } +}; + +app.prototype.onKeyPress = function( e ) { //console.log("onKeyPress"); this.keypress = true; if ( e.which === 229 ) { @@ -52,23 +68,7 @@ app.prototype.onKeyPress = function() { } }; -app.prototype.onKeyUp = function() { - //console.log("onKeyUp"); - this.keyup = true; - if ( this.inime ) { - this.inime = false; - } -}; - -app.prototype.onKeyDown = function( e ) { - //console.log("onKeyDown"); - this.keydown = true; - if ( e.which === 229 ) { - this.inime = true; - } -}; - -app.prototype.onMouseDown = function() { +app.prototype.onMouseDown = function( e ) { this.mousedown = true; if ( this.inime ) { @@ -81,6 +81,24 @@ app.prototype.loopFunc = function() { if(text != this.prevText) { + console.log("text is different"); + + if(this.keydown) { + console.log("keyboard"); + } else { + console.log("not keyboard"); + } + + this.prevText = text; + } + + this.keypress = false; + this.keyup = false; + this.keydown = false; + this.mousedown = false; + + /* + var selection = rangy.getSelection(); @@ -116,6 +134,7 @@ app.prototype.loopFunc = function() { this.keyup = false; this.keydown = false; this.mousedown = false; + */ }; app.getDOMText = function( elem ) {