keydown
img
active
tabindex

interactive tabindex='-1'

-demo https://codepen.io/gnjo/pen/ZZXrGY

-delete keyを押すと自身を削除する。

///core

el.setAttribute('tabindex','-1') //interactive-able


let fn={}
fn.deleteMe=function(el){
let is={};
is.element=function(o){return !!(o && o.nodeType === 1)}
;
if(!is.element(el)){
console.log('delemteMe not element',el)
return el;
}
el.setAttribute('tabindex','-1') //interactive-able
el.style.outline='none'
el.onkeydown=(e)=>{
if(e.which===46) e.target.remove();//46 delete
}
return el;
}

let a=document.querySelector('#a')
a.onkeydown=(e)=>{
console.log(e.type,e)
}
let b=document.querySelector('#b')
fn.deleteMe(b)///////

<img id="a" src="https://i.imgur.com/KkuF4ga.png">

<img id="b" src="https://i.imgur.com/KkuF4ga.png">