PDA

View Full Version : Controlling the "tab" event in textarea


Terry
09-16-2002, 04:03 AM
Hi, I'm making a simple JavaScript editor that allows the contents of my textarea to write in a new popup window. It works pretty good except for one thing. I would like to add the functionality of the tab's "\t" that occurs in other editors such as textpad (instead of the onFocus() onBlur() that happens in forms). I succeded in capturing the onKeyDown event (in IE),


document.onkeydown = stopAction;

function stopAction()
{

if(event.keyCode == 9)
{

// Code to make the cursor move horizontally?



return false;

}

}


now I want to cause the cursor to move like it does in normal applications. I tried alert(event.screenX + " - " event.screenY), are these the coords for the cursor when I hit the tab? If so, how would I move the cursor in the textarea?

Thanks,
Terry

glenngv
09-16-2002, 06:29 AM
read this article

http://www.siteexperts.com/tips/elements/ts34/page1.asp

Terry
09-16-2002, 07:41 AM
Thanks alot. That's what I was looking for.