Capturing the tab key

samsmithnz

Senior Contributor
Joined
Jul 22, 2003
Messages
1,038
Location
Boston
I'm trying to capture the tab key in my ASP.NET app, I want it to select the first item in the menu. I've added this line to enable my control to recoginise keypresses:
Code:
txtEmployee.Attributes.Add("onkeyup", "ProcessKeyPress()")

and then with the javascript function:
Code:
function ProcessKeyPress()
{
    var SourceField = event.srcElement;
				
    if(event.keyCode == 9)
    {
        alert('tab pressed!!!');
    }
}

This captures lots of other keys... (including enter, shirt, ctrl, etc) just not the tab key... it just tabs off the textbox...

what can I do?
 
Last edited:
as far as i know is javascript clientside language und asp (active SERVER page) a server sided page.. so you still have to use javascript, java applet, flash, which are all clientsided
 
NK2000 said:
as far as i know is javascript clientside language und asp (active SERVER page) a server sided page.. so you still have to use javascript, java applet, flash, which are all clientsided

which is what I'm trying to do. Capture the Tab key using javascript, as I said up above.
 
oh i was irritated by " I'm trying to capture the tab key in my ASP.NET app"

Code:
<script type="text/javascript">
<!--
window.captureEvents(Event.KEYPRESS);
window.onkeypress = Input;
function Input(event) {
 alert("You pressed: " + event.which );
}
//-->
</script>

maybe this helps to get the name for tab only
 
Back
Top