Skip to content

Instantly share code, notes, and snippets.

@AlekseyArh
Last active December 15, 2020 16:37
Show Gist options
  • Save AlekseyArh/8be628265b8acc31fc0c6f80a99291a1 to your computer and use it in GitHub Desktop.
Save AlekseyArh/8be628265b8acc31fc0c6f80a99291a1 to your computer and use it in GitHub Desktop.
Tab в textarea
$('body').on('keydown', 'textarea', function (event) {
if (event.keyCode === 9) {
let v = this.value, s = this.selectionStart, e = this.selectionEnd;
this.value = v.substring(0, s) + '\t' + v.substring(e);
this.selectionStart = this.selectionEnd = s + 1;
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment