I'm trying to create jQuery that will indent a div when the tab
key is pressed. I found this code, which works fine:
$('[contenteditable]').on('keydown', function(e) {
if(e.keyCode == 9){
e.preventDefault();
document.execCommand('insertHTML', false, '	');
}
});
However, when looking at the API documentation (https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand), it states:
Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Are there any alternatives to using .execCommand()
?