I am trying to run a function on Keyup of the TinyMCE Editor on new post and edit post screens.
I’m having a hard time catching the keyboard action when a user types something.
jQuery(document).ready(function() {
setTimeout(function(){
var content = "tinymce";
var tinyMCEcontent = tinymce.editors.content.getContent();
console.log(tinyMCEcontent.length);
},3000);
});
This was my attempt at getting the content of the TinyMCE editor. I am able to see the length. How can I run this function on Keyup? I have tried something like this:
jQuery(document).ready(function() {
jQuery("#tinymce").keyup(function() {
setTimeout(function(){
var content = "tinymce";
var tinyMCEcontent = tinymce.editors.content.getContent();
console.log(tinyMCEcontent.length);
},3000);
});
});
But it isn’t catching the keyup at all.
What I am trying to do is set a limit on the post type content.
http://www.tinymce.com/wiki.php/api3:event.tinymce.editor.onkeyup
For WordPress 3.9+ running tinymce 4: