Tab inside textarea element in Typescript/Angular

Published

i cannot find a solution of my issue with the tab inside a textarea. Everytime i use tap button it jumps to another textarea. Now I have come across a solution, which is, however, written in Javascript (Another one i found is written with jQuery) – but unfortunately I can’t find a solution for Typescript.

This is what i got for now (written 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;
       }
    });

I really can’t find anything and Stackoverflow is the last port of call for my problem. Maybe one of you can help me 🙂

Big thanks in the front!!

greez
Julian

Source: Angular Questions

Published
Categorized as angular, javascript, tabs, textarea, typescript Tagged , , , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq