Rodolfo
8
Q:

css permit tabs on textarea react

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

Tags

New to Communities?

Join the community