Using default wordcount javascript in WordPress on custom wp_editor() areas

Git this to work by using the following line of code in my theme’s functions.php.

$wordcount = str_word_count( strip_tags( $content ), 0 );

I got this piece of code from a stackoverflow post.

The only disadvantage with this code is that it does not update dynamically which is not a big issue as the current wordcount will show up every time the post is updated.

The problem with using javascript on which event I should trigger the wordpress function on.

WordPress’s wordcount functionality is tightly coupled with the default editor and I had to duplicate their javascript to try and get similar functionality which is not a good choice.

I would still like to get some thoughts on this by a more experienced WP developer.

Thank you.
nav