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

jquery sample code to get keycode_jquery

WBOY
Release: 2016-05-16 17:06:12
Original
951 people have browsed it

As shown below:

Copy code The code is as follows:

txtSearch: Text box ID

$("#txtSearch").keyup(function (event) {
var keycode = event.which;
if (keycode == 13) {
alert('You have pressed return Car key');

}

});

or

xObj.keyup(function(event){
//Get the key value of the current key
//There is a which attribute on the jQuery event object to get the key value of the keyboard key
var keycode = event.which;
//Handling carriage return
if(keycode==13){

}
//Handling esc
if(keycode == 27){

                                                                                         🎜> //There is a which attribute on the jQuery event object to get the key value of the keyboard key
var keycode = event.which;
//Handle the carriage return situation
if(keycode==13 ){

}
//Handling esc
if(keycode == 27){

}
}
}); >

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