prosekit/pm/keymap
Re-exports from prosemirror-keymap.
Functions
Section titled “Functions”keydownHandler()
Section titled “keydownHandler()”-
function keydownHandler(
bindings
:object
): (view
:EditorView
,event
:KeyboardEvent
) =>boolean
-
Given a set of bindings (using the same format as
keymap
), return a keydown handler that handles them.
keymap()
Section titled “keymap()”-
function keymap(
bindings
:object
):ProseMirrorPlugin
-
Create a keymap plugin for the given set of bindings.
Bindings should map key names to command-style functions, which will be called with
(EditorState, dispatch, EditorView)
arguments, and should return true when they’ve handled the key. Note that the view argument isn’t part of the command protocol, but can be used as an escape hatch if a binding needs to directly interact with the UI.Key names may be strings like
"Shift-Ctrl-Enter"
—a key identifier prefixed with zero or more modifiers. Key identifiers are based on the strings that can appear inKeyEvent.key
. Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held). You may use"Space"
as an alias for the" "
name.Modifiers can be given in any order.
Shift-
(ors-
),Alt-
(ora-
),Ctrl-
(orc-
orControl-
) andCmd-
(orm-
orMeta-
) are recognized. For characters that are created by holding shift, theShift-
prefix is implied, and should not be added explicitly.You can use
Mod-
as a shorthand forCmd-
on Mac andCtrl-
on other platforms.You can add multiple keymap plugins to an editor. The order in which they appear determines their precedence (the ones early in the array get to dispatch first).