0

How to add empty space characters in a TextArea

When I press the TAB key I would like my text to append four empty spaces from where I selected my text, but my code doesn't seem to work and instead is glitching my TextArea. document.getElementById('code-area').addEventListener('keydown', function(event) { if (event.key == 'Tab') { event.preventDefault(); this.value += ' '; } });

27th Mar 2021, 5:24 PM
Frumkin
Frumkin - avatar
1 Respuesta
+ 1
tried to call event.preventDefault() at begin?
27th Mar 2021, 5:36 PM
KrOW
KrOW - avatar