Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture 'tab' key

Status
Not open for further replies.

Mariano01

Programmer
Joined
Jan 11, 2006
Messages
4
Location
AR
I´m having a problem, i need the TAB key to follow a sequence, but i don´t know how to avoid it to go to the bars of the explorer.
Is that possible?

Thanks!

Mariano Carpentier
 
There is a TABINDEX attribute in HTML that should dictate where the cursor goes when you tab through a page. I have not had much luck with it, however.

In Internet Explorer, you can use the keyCode attribute of the event object to check for tab and respond accordingly:

Code:
<script>
function tabNext()
{
 if(event.keyCode == <whatever it is for TAB>)
 {
  <put focus where I want it>
  return false;
 }
 else
 {
  return true;
}
</script>
...
<input type='text' onkeydown = 'tabNext()' />

Other browsers have other ways of capturing a key (like a TAB), so if you need to be cross-browser friendly, you'll want to look into those as well. Their methods will be similar to this.

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top