how to bind key combination ctrl+x+return in jquery

后端 未结 5 688
闹比i
闹比i 2021-01-02 16:59

Is there any way to catch key combination ctrl+x+return in jquery(or javascript), such that if user presses this key combination, a function

5条回答
  •  难免孤独
    2021-01-02 17:51

    You can use the ctrlKey property of the key press event object

    $(document).keypress(function(e) {
        if(e.ctrlKey) {
            // do code to test other keys
        }
    });
    

    Also shift, alt reserved keys have properties, but the enter key has keyCode 13.

    Is there any reason you can't to try a different combination - e.g. ctrl-alt-x? Enter key is usually reserved for triggering form submits and other events on a web page.

提交回复
热议问题