jQuery Capture Copy, Paste and Cut Events

Sam Deering
Share

This is how you can capture if someone has copied, cut or pasted into a input text area.

Demo

Copy, cut or paste text from/to the text area below.


The Code

(function($)
{
    $(document).ready(function() {

        $("#textinput").bind({
            copy : function(){
                $('#eventresult').text('copy behaviour detected!');
            },
            paste : function(){
                $('#eventresult').text('paste behaviour detected!');
            },
            cut : function(){
                $('#eventresult').text('cut behaviour detected!');
            }
        });

    });
})(jQuery);