Tab key inside div

R

rodchar

hey all,
is it possible to simulate the Tab key inside a Div element?

thanks,
rodchar
 
M

Mark Rae [MVP]

is it possible to simulate the Tab key inside a Div element?

Not sure what you mean...

The Tab key will set focus to the next editable element horizontally then
vertically - is this not what you want...?
 
R

rodchar

no, i mean tab over spaces.

Mark Rae said:
Not sure what you mean...

The Tab key will set focus to the next editable element horizontally then
vertically - is this not what you want...?
 
M

Mohamad Elarabi

Not exactly an ASP.Net question but here is my response:

You can try placing a OnKeyPress or an OnKeyDown event on the div and have
them call a js function.

Your function should check the value of event.keyCode to see if tab was
pressed or not. I think the keycode for tab is 8 but I could be wrong. If it
is tab then append 4 or 8 spaces to the div's innerHTML/innerText etc then
make sure to return false and cancel event bubbling so the browser won't tab
to the next control.

Something like this

<div id="blah" onKeyPress="doTab;"></div>

<script language="jscript">
function doTab()
{
if event.keyCode == 8
{
document.all.item("blah").innerHTML += " ...";
event.returnValue = false;
event.cancelBubble = true;
};
}

</script>

Hope that works for you.
 
R

rodchar

thanks for the help everyone.
rod.

Mohamad Elarabi said:
Not exactly an ASP.Net question but here is my response:

You can try placing a OnKeyPress or an OnKeyDown event on the div and have
them call a js function.

Your function should check the value of event.keyCode to see if tab was
pressed or not. I think the keycode for tab is 8 but I could be wrong. If it
is tab then append 4 or 8 spaces to the div's innerHTML/innerText etc then
make sure to return false and cancel event bubbling so the browser won't tab
to the next control.

Something like this

<div id="blah" onKeyPress="doTab;"></div>

<script language="jscript">
function doTab()
{
if event.keyCode == 8
{
document.all.item("blah").innerHTML += " ...";
event.returnValue = false;
event.cancelBubble = true;
};
}

</script>

Hope that works for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top