Reputation: 3424
I want to know the how to handle when user press up arrow when focused on a textbox
Upvotes: 0
Views: 239
Reputation: 219087
You can grab the event itself by binding to the keyup event with jQuery. As for determining which key was pressed, here's a quick little tutorial on key codes in JavaScript. You can adapt this code to check against the key being pressed in the event.
They key code you're looking for (the up arrow) is 38
.
Upvotes: 2
Reputation: 12279
$("input_selector").focus(function(){
$(this).bind("keyup", function(e){
if ( e.keyCode == 39){
//do what you want with the up arrow
}
});
});
$("input_selector").blur(function(){
$(this).unbind("keyup");
});
Upvotes: 1