Skip to content

Can I add new shortcut keys? #3750

Answered by moy2010
gorimatyan asked this question in Q&A
Jan 18, 2023 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

You can do it like this:

const [editor] = useLexicalComposerContext();

useEffect(() => {
  return mergeRegister(
    editor.registerRootListener((rootElement) => {
      if (rootElement) {
        rootElement.addEventListener('keydown', yourKeyDownHandler);
      }
    })
  )
}, [editor, editorReadCallback]);

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@moy2010
Comment options

@gorimatyan
Comment options

@gorimatyan
Comment options

@moy2010
Comment options

@gorimatyan
Comment options

Answer selected by gorimatyan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants