Search code examples
javascriptjqueryhtmltextareaindentation

Override TAB inside a Browser


If I'm typing text in a input field and press ENTER the default behavior of all the browsers I know is to submit the form, however if I press ENTER inside a textarea a new line is added.

Is there any way to mimic this behavior (indent, not submit the form) whenever I press TAB inside a textarea? Bespin seems to do it, but in a canvas element.


Solution

  • I haven't done it myself, but it seems to be possible to override the event handler and catch the key. See e.g. here.

    Oh and for the JQuery crowd there even is a plugin.