Home >Web Front-end >JS Tutorial >jQuery ctrl Enter shift Enter implementation code_jquery

jQuery ctrl Enter shift Enter implementation code_jquery

WBOY
WBOYOriginal
2016-05-16 18:35:24969browse

The key code can be found through the event's which
However, when there is a key combination, you need to pay attention
such as the ctrl enter key. Although e.ctrlKey is used, the key code of the enter key is not always 13
In ff, it is determined that ctrl enter is e.ctrlKey && e.which ==13
In ie6, it is determined that ctrl enter is e.ctrlKey && e.which ==10
Example:

Copy code The code is as follows:

$(document).keypress(function(e){
if(e. ctrlKey && e.which == 13 || e.which == 10) {
$("#btn").click();
} else if (e.shiftKey && e.which==13 || e.which == 10) {
$("#btnv").click();
}
})
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn