How to keymap with Esc keyboard

I want to keymap with ESC. I tried like this, but when I keypress ESC, it doesn’t affect any response.

function createState(defaultValue) {
  return EditorState.create({
    doc: defaultMarkdownParser.parse(defaultValue),
    plugins: [
      keymap(buildKeymap(schema)),
      keymap(baseKeymap),
      keymap({"Esc": (state, dispatch, view) => { console.log(view)}})
      history(),
      placeholder(),
    ]
  });
}

I checked baseKeymap, but couldn’t find about Esc How can I improve this?

Are you using prosemirror-example-setup? It binds esc: https://github.com/ProseMirror/prosemirror-example-setup/blob/master/src/keymap.js.

Thanks, I missed that point, That works fine. It is selecting parentnode. But actually I want to get out focus mode when click Esc button, How about the Tab key? I need to add a custom event when click Tab, so exactly, I want to add 4 spans when press Tab. But for now, when I press Tab, it works with accessibility, which means it gets out focus in the editor.

But actually I want to get out focus mode when click Esc button, How about the Tab key? I need to add a custom event when click Tab, so exactly, I want to add 4 spans when press Tab. But for now, when I press Tab, it works with accessibility, which means it gets out focus in the editor.

ProseMirror, when executing a keypress, will check the plugins in the order they are initialized, and will stop on the first key-handler that returns true.

So if you want your custom key-handlers to execute first, move them:

    plugins: [
      keymap({
        // These handlers should return true or false
        "Esc": customEscHandler,
        "Tab": customTabHandler,
      })
      keymap(buildKeymap(schema)),
      keymap(baseKeymap),
      history(),
      placeholder(),
    ]

Thanks, I appreciate it.