Prevent keybinding in handleKeyDown function


I’m using baseKeyMap of prosemirror-commands which handles pressing enter.

I try to implement mentions and when a dropdown of users appears I want to press enter to insert the selected user. So I tried to prevent the default enter handler for this specific case within a plugin but this doesn’t work. The default enter handler is always called.

return new Plugin({
  props: {
    handleKeyDown(view, event) {
      if (event.keyCode === 13) {
        // not working

Is there any other way to do this?


You have to return true from handleKeyDown to prevent further handlers from running, and make sure your plugin comes before the default keymap in the list of plugins.


Ah, return true solved it for me. Thank you for your fast response!