tab indent in textarea code example
Example 1: tab adds tab textarea javascript
$(document).delegate('#textbox', 'keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
e.preventDefault();
var start = this.selectionStart;
var end = this.selectionEnd;
$(this).val($(this).val().substring(0, start)
+ "\t"
+ $(this).val().substring(end));
this.selectionStart =
this.selectionEnd = start + 1;
}
});
Example 2: css permit tabs on textarea react
<ConfigurationInput onKeyDown={e => {
if ( e.key === 'Tab' && !e.shiftKey ) {
document.execCommand('insertText', false, "\t");
e.preventDefault();
return false;
}}}/>