Jquery gets the sample code for keycode
- 2020-03-30 01:08:47
- OfStack
As follows:
txtSearch: The text box ID
$("#txtSearch").keyup(function (event) {
var keycode = event.which;
if (keycode == 13) {
alert(' You've hit enter ');
}
});
or
xObj.keyup(function(event){
//Gets the key value of the current key
//JQuery has a which property on the event object to get the key value of the keyboard key
var keycode = event.which;
//Handle the return case
if(keycode==13){
}
//Handle the esc situation
if(keycode == 27){
}
});
or
$(document).keyup(function(event){
//Gets the key value of the current key
//JQuery has a which property on the event object to get the key value of the keyboard key
var keycode = event.which;
//Handle the return case
if(keycode==13){
}
//Handle the esc situation
if(keycode == 27){
}
});