This article mainly introduces jquery's sample code for obtaining keycode. If you need it, you can refer to it and hope to help you as follows:
The Code is as follows:
TxtSearch: text box ID
$ ("# TxtSearch"). keyup (function (event ){
Var keycode = event. which;
If (keycode = 13 ){
Alert ('you have pressed the enter key ');
}
});
Or
XObj. keyup (function (event ){
// Obtain the key value of the current button
// The jQuery event object has a which attribute to obtain the key value of the keyboard key.
Var keycode = event. which;
// Handle the carriage return status
If (keycode = 13 ){
}
// Handle the esc status
If (keycode = 27 ){
}
});
Or
$ (Document). keyup (function (event ){
// Obtain the key value of the current button
// The jQuery event object has a which attribute to obtain the key value of the keyboard key.
Var keycode = event. which;
// Handle the carriage return status
If (keycode = 13 ){
}
// Handle the esc status
If (keycode = 27 ){
}
});