document.addEventListener('keyup',e=>{
if(e.key==='Escape'){
document.designMode='off';
s.remove();
}
},{once:true});
The handler will run only once, whether Escape was pressed or not, which means that it will stop working after the first key press. Instead of {once:true}, I guess you want to removeEventListener inside the if block.
The handler will run only once, whether Escape was pressed or not, which means that it will stop working after the first key press. Instead of
{once:true}, I guess you want toremoveEventListenerinside theifblock.