Home >Web Front-end >JS Tutorial >jquery sample code to get keycode_jquery
As shown below:
$("#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){
}
}
}); >