Word Count with Jquery, need some help please !!!

Word Count with Jquery, need some help please !!!

I'm using K2 Smartforms and essentially have a Text Area (its named textarea)

Underneath the text area there are two data labels, one called WordCount, the other is called Script.

Wordcount label stores the actual word count

Script, has Literal property ticked and the following expression:

<script async defer>$(document).ready(function () { var wrdCountDataLabel = $("[name='WordCount']"); wrdCountDataLabel.parent().find('input[type=text], textarea').keydown(function () { var s = $(this).val() .replace(/(^\s*)|(\s*$)/gi,"") .replace(/[ ]{2,}/gi," ") .replace(/\n /,"\n"); var wordCount = s.split(" ").length; if (wordCount === NaN) wordCount = 0; wrdCountDataLabel.SFCLabel('option', 'text', wordCount); });});</script>

If the user types in the text area, the above script counts each "space" and updates the count, however if a user copy and pastes text into the textarea, nothing happens unless the user pressing a space character after copy and pasting...

Pressing the space character on the keyboard isn't something a user would do when copying and pasting, so I need your help.

Please can anyone help get this working so the wordcount will work whether typing or copying and pasting in the textarea.

Happy to try anything you guys can suggest.

Thanks