Here is a demo plunkr link that I have created to demonstrate the issue.
I am looking to implement the strikeThrough
command whenever there is a delete operation. For instance:
If the user selects "Text" and presses the delete
or backspace
key, it should be displayed as Test. It shouldn't just disappear.
Can anyone provide assistance with this?
$container.bind('keydown keyup', function (e) {
console.log(e)
if(e.keyCode===8 || e.keyCode===46){
$document[0].execCommand('strikeThrough', false); // line 1
e.preventDefault(); // line 2
}
});
I can capture the events as shown above, but facing difficulties in making both line 1
and line 2
work together. Is there a way to prevent the deletion event and execute the execCommand
successfully?