键盘功能不适用于CKEditor 4

时间:2018-06-18 09:48:12

标签: javascript ckeditor ckeditor4.x

我正在使用CKEditor 4但是当我将keyup事件应用于它时,它无效。代码是:

HTML code:

<div class="col-md-9">
    <div class="wc" id="wcso"></div>
    <div id="storyOutlineCircle1" class="badge badge-success round storyOutlineCircleClass" style="position: absolute;right:30px;bottom:0px;">100</div>
    <textarea id="storyOutline" rows="5" class="form-control" name="labinputstory" placeholder="Story Outline" required></textarea>
</div>    

JS代码:

<script>
       var e = CKEditor.instances['labinputstory']
       e.on( 'keyup', function( event ) {
           alert( e.getData() );
       });
</script>

1 个答案:

答案 0 :(得分:0)

CKEditor只有一个key event。如果您希望使用keyUp,则需要将其附加到编辑editable,如下所示:

var editor = CKEDITOR.replace( 'editor1', { /*editor instance configuration goes here*/ });
editor.on( "pluginsLoaded", function( event ){              
    editor.on( 'contentDom', function( evt ) {
        var editable = editor.editable();                   
        editable.attachListener( editable, 'keyup', function( e ) { 
            var keyCode = e.data.getKeystroke();
            // if ( keyCode == ... )
        });
    }); 
});