Last active
December 15, 2020 16:37
-
-
Save AlekseyArh/8be628265b8acc31fc0c6f80a99291a1 to your computer and use it in GitHub Desktop.
Tab в textarea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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