One way is to cache the length outside the handler, and then compare the current length of the text field with the cached length. If they differ from each other, you can take the key to which the added content was added to the text field. Hope this helps.
var textarea = $('textarea').get(0),
length = $(textarea).val().length;
$(textarea).keyup(function() {
if($(this).val().length != length) {
length = $(this).val().length();
}
});
source
share