Skip to content

Escape key handler doesn’t work after one key press #1

@simevidas

Description

@simevidas
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions