Select Page

This following script sets an event listener on the CKEditor instance and gets triggered on every keyup event. It then retrieves the data from the editor, removes any HTML tags from it using a regular expression, and counts the remaining characters. Finally, it logs the character count to the console.

var editor = CKEDITOR.instances['your-editor-id'];
editor.on('key', function() {
    var count = editor.getData().replace(/<[^>]*>/g, '').length;
    console.log('Character count: ' + count);
});

DEMO

See the Pen Untitled by Puneet Sharma (@webdevpuneet) on CodePen.