Reputation: 8192
I'm working with a contentEditable area (in Chrome specifically at the moment).
If I capture the delete key press, is it possible to know what the next element or text is that is to be deleted?
What I'm really wanting to test is if the next item to delete is a
<div class="clearfix"></div>
Then I don't want to delete it.
I was looking at treeselection here: https://developer.mozilla.org/en/XUL_Tutorial/Tree_Selection but wasn't really clear on how to implement it if this is even what I need to be looking at.
Upvotes: 0
Views: 85
Reputation: 8192
Nevermind guys. This was a dumb question. All I simply needed to do is see if I'm at the end of the current node, if I am don't do anything.
Sometimes I make things more complicated than they really are.
Something like this worked for me:
if(event.keyCode == 46){
var s = document.getSelection();
if(s.anchorOffset == s.anchorNode.length){
return false;
}
}
Upvotes: 1