Prevent the node deletion on space keypress

If the node is selected and I press the space key then the node is deleted. How to prevent the deletion of node on space keypress

It’s replaced with a space. Something similar happens when you press another character-producing key.

You could bind some command to space if you want space to do something else.

So, what if I don’t want to insert anything means it should do nothing

    export function spaceKeyPress(state, dispatch) {
      if(state.selection.node?.type) {
        // this should not happen state.tr.insertText(' ')..scrollIntoView()
      }
    // default behaviour
    }

Yes, just return true in the keymap handler

...
plugins: 
[
...
      keymap({
        'Space': (state, dispatch, view) => {
          if (decide what to check) {
               return true; //do not accept key press
            }
            // this will return false otherwise, i.e. accept the key
        },
...
]

edit: true in this case means that you have handled the key press yourself and ProseMirror does not need to do anything else.

Thanks, that is working