Ctrl + Shift + v Chrome事件监听器(获取复制的文本)

时间:2015-06-26 06:00:11

标签: javascript google-chrome

我想为快捷键 Ctrl + Shift + v (粘贴纯文本)编写事件监听器是否可能?如果是这样,任何人都可以分享如何写它。首选是纯Javascript监听器。

编辑:我希望在完成之前获取要在我的编辑器中粘贴的文本。

1 个答案:

答案 0 :(得分:0)

You can handle key's with jQuery handler keydown. Simple example with ctrl+shift+v

var first = null;
var second = null;
var third = null;
$(document).on('keydown', function ( e ) {

    if(first == null) {
        first = e.which;
    } else if(second == null) {
        second = e.which;
    } else if(third == null) {
        third = e.which;
    }
    if(first == 17 && second == 16 & third == 86) {
        alert( "You pressed CTRL + SHIFT + V" );
        first = null;
        second = null;
        third = null;
    }
});

$(document).on('keyup', function( e ) {
    first = null;
    second = null;
    third = null;
});