I\'ve defined the following two span elements: 1) element inside a contenteditable div. 2) contenteditable element.
So far, I can\'t get the onkey events to fire
You could try using the new window.getSelection() API through which you could access the leaf-most node that is part of your current selection. I.e:
One
Two
JS:
function getTarget(ev) {
const selection = window.getSelection();
// assuming your cursor is over "One"
console.log(selection.baseNode.parentNode) //
}
May or may not meet your requirements.