How do I catch Escape key and prevent dialog from closing?

For the sp-menu use case, if it’s embedded in an sp-popover and the user has opened the popover, ESC will only close the popover.

Example:

<sp-overlay>
  <sp-action-button slot="trigger">Click</sp-action-button>
  <sp-popover offset="0" placement="below" alignment="left" appearance="none" slot="click">
    <sp-menu style="width:100px">
       <sp-menu-item>Chicago</sp-menu-item>
       <sp-menu-item>Chicago</sp-menu-item>
       <sp-menu-item>Chicago</sp-menu-item>
       <sp-menu-item>Chicago</sp-menu-item>
    </sp-menu>
  </sp-popover>
</sp-overlay>

But popovers will wreak havoc with focus, so while you can force the popover to appear outside of a user interaction (like clicking on this button) as part of an autocomplete control, the popover will steal focus… so may not work in this particular case.