KeyboardShortcut
interfaceImport
import { KeyboardShortcut } from '@modular/sdk/editor';Members8
- $disabledoptional
(selection: null | BaseSelection, editor: LexicalEditor) => booleanCalled with the current selection before the command is dispatched; returning true skips this shortcut (falling through to any other shortcut on the same key and modifiers). Menu builders may use the same predicate to render an item as disabled.
- $dispatchoptional
(command: LexicalCommand<KeyboardEvent>, event: KeyboardEvent, $next: () => boolean, editor: LexicalEditor) => booleanOptional middleware around the command dispatch, for shortcuts that must run additional code (e.g. setting some state) without defining a wrapper command. It is responsible for calling `$next()` — which dispatches the command on the originating editor — and returning whether the event was handled (an unhandled event falls through to any other shortcut on the same key and modifiers).
- bubbleFromNestedEditorsoptional
booleanBy default, shortcut keypresses that originate in nested editors but were not handled by that editor are ignored. Set to `true` when you want matching events to bubble up to this handler. This only has an effect when the shortcut listener is registered at a priority above `COMMAND_PRIORITY_EDITOR`: the nested editor registers the core key-down handler at that priority and it always reports the event as handled, which ends the dispatch before it reaches the outer editor's editor-priority queue.
- command
LexicalCommand<KeyboardEvent>The command dispatched with the matched KeyboardEvent as its payload. The event is considered handled when the dispatch is handled; an unhandled dispatch falls through to any other shortcut on the same key and modifiers. Listeners are responsible for calling `event.preventDefault()` if the default action must be suppressed.
- descriptionoptional
stringA human readable description of what the shortcut does, for building menus or help dialogs from a shortcut table
- key
stringThe `KeyboardEvent.key` to match, case-insensitive (e.g. `'b'`, `'1'`, `'Enter'`, `'ArrowLeft'`)
- modifiersoptional
KeyboardEventModifierMaskThe expected state of the modifier keys. A modifier that is omitted or `false` must not be pressed, `true` must be pressed, and `'any'` is ignored. The default of `{}` matches only events with no modifiers.
- unshiftedKeyoptional
stringThe unshifted key to display to the user, only relevant when the shift modifier is true on non-Apple environments.