Created
May 30, 2020 15:06
-
-
Save tksugimoto/4321a2d7d60c729937f7495a0eea78d2 to your computer and use it in GitHub Desktop.
<textarea> にフォーカスがある状態で Tab キー押下で インデントする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.body.addEventListener('keydown', event => { | |
if (event.key === 'Tab' && event.target.tagName === 'TEXTAREA') { | |
document.execCommand('insertText', /* ShowDefaultUI = */ false, ' '); | |
event.preventDefault(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment