How to detect Ctrl+V, Ctrl+C using JavaScript?

前端 未结 17 2078
走了就别回头了
走了就别回头了 2020-11-22 13:47

How to detect ctrl+v, ctrl+c using Javascript?

I need to restrict pasting in my textareas, end user should not copy and p

17条回答
  •  旧巷少年郎
    2020-11-22 14:50

    With jquery you can easy detect copy, paste, etc by binding the function:

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

    More information here: http://www.mkyong.com/jquery/how-to-detect-copy-paste-and-cut-behavior-with-jquery/

提交回复
热议问题