I am struggling to find a solution for the issue I'm experiencing with tabs inside a textarea. Every time I press the tab button, it jumps to another textarea. I have found some solutions written in JavaScript and jQuery, but unfortunately, I can't seem to find one for Typescript.
Here is what I have so far (in JS):
document.getElementById('textbox').addEventListener('keydown', function (e) {
if (e.key == 'Tab') {
e.preventDefault();
var start = this.selectionStart;
var end = this.selectionEnd;
this.value = this.value.substring(0, start) + '\t' + this.value.substring(end);
this.selectionStart = this.selectionEnd = start + 1;
}
});
<textarea pInputTextarea tabindex="0" (keydown)="handleKeydown($event)" onFocus="this.select();" (input)="setOkayButtonMode()"
[rows]="10" [cols]="75" maxlength="255">
</textarea>
I am running out of options and turning to Stackoverflow as a last resort for help with my problem. Hopefully, someone here can assist me :)
Thank you in advance!!
Best regards, Julian