BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Question: How to add/overwrite keyboard shortcuts?

Open rockiger opened this issue 11 months ago • 2 comments

I would like to add a keyboard shortcut for Ctrl+Enter. What would be the best way to do that?

Adding keyboard listeners on document or BlockNoteView doesn't work because BlockNote/Tiptap/PM reacts to the Enter key first.

rockiger avatar Mar 27 '24 17:03 rockiger

I am facing this issue too. Inside bullet points and nesting, the standard approach to unnest in every other text editor is to use Enter, but here its Shift+Tab. It converts to paragraph if clicking Enter. The code is very deeply nested and does not seem possible to change.

Is there a way we can have greater control over these shortcuts?

image

james-pratama avatar Apr 05 '24 19:04 james-pratama

Shortcuts and input rules are planned but no ETA on those yet. In the meantime, you should be able to override the default shortcuts like so:

<BlockNoteView
  editor={editor}
  onKeyDownCapture={(event) => {
    if (event.key === "Enter") {
      event.preventDefault();
      alert("Hello");
    }
  }}
/>

matthewlipski avatar Jun 11 '24 13:06 matthewlipski