![]() |
tab key emulation
Basically what I'd like to achieve is when a user hits the tab key within a textarea it actually tabs out, I'm not much for javascript and I've tried researching and only came up with looking out for the key event 9 using windows.event or the netscape equivalent.
|
Hmmmm maybe you could insert a certain number of spaces when the user presses TAB?
Anyway, I think it's a little annoying too. Everytime I'm writing a piece of code here in the forums I always press TAB to try to indent the code. :-P |
You basically need to overwrite the default command for the TAB key inside that textarea only (e.g. if the textarea is focused). I think you can easily insert a \t and a tab space will appear (it works with newlines, so it *should* work with tabs, as well). It's better to test first, though, just in case :-)
|
Hi Andres,
this script I found a while ago should help. It's not very nice code and it's also not unobtrusive, but it should work with most browsers. Code:
<html> |
That's a good find you have there sidisinsane, the only problem is it adds spaces, not tabs. You can easily fix this though by switching out a few lines:
Code:
<html> |
I say its nicer with the JQuery manipulation of the regular keycodes ;)
|
True, but the minified version of jquery.js is over 58 KB. This is only 1.5 KB including all of the HTML. It really depends on if you are doing just this or if you are also using jquery for something else on the same page (and or site).
|
Very True ;)
|
Forgot to mention...I took the above script and modified (it was creating tabs and kept on going to the next button). Works a charm now - thanks!
|
Quote:
|
Quote:
|
| All times are GMT. The time now is 11:07 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0