Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bookmarklet: allow tabs in textareas (requires jQuery) Create a toolbar bookmark with this code. Click it when you want to be able to use tabs in a textarea.
javascript:$(document).delegate('textarea', 'keydown', function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); var start = $(this).get(0).selectionStart; var end = $(this).get(0).selectionEnd; $(this).val($(this).val().substring(0, start) + "\t" + $(this).val().substring(end)); $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1; }});void(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment