Home > Web Front-end > JS Tutorial > body text

jQuery ctrl Enter shift Enter implementation code_jquery

WBOY
Release: 2016-05-16 18:35:24
Original
947 people have browsed it

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();
}
})
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template