1document.querySelector('#textarea').addEventListener('keydown', e => {
2 if ( e.key === 'Tab' && !e.shiftKey ) {
3 // execCommand operations are "Cmd|Ctrl+Z"-able
4 // note: execCommand is deprecated and may not work in the future
5 document.execCommand('insertText', false, "\t");
6 e.preventDefault();
7 return false;
8 }
9});