How to detect right mouse click + paste using JavaScript?

I like this solution:

$('#txt_field').bind('input propertychange', function() {
   console.log($(this).val());
});

$('#controlId').bind('paste', null, function(e) {
    if(!e.keyCode){
       /*
          since no key was down at the time of the event we can assume it was
          from the toolbar or right click menu, and not a ctrl+v
       */
    }
});

With IE you have onpaste

With Mozilla you can look into oninput and

elementReference.addEventListener("DOMCharacterDataModified", function(e){ foo(e);}, false);

There is no easy as pie solution.

Eric


Use setTimeout(), set small timeout till .val() func can get populated.

$(document).on('paste blur keyup', '#controlId', function(event) {
    var element = $(event.target);
    setTimeout(function() {
        var text = $(element).val();
        // do something with text
    }, 100);
});

Source: Catch paste input