KeyboardEventDefinition
KeyboardEventDefinition = ({
code:KeyboardEvent["code"];key:KeyboardEvent["key"]; } | {code?:undefined;key:KeyboardEvent["key"]; } | {code:KeyboardEvent["code"];key?:undefined; }) &object
Defined in: keyboard-event-definition.ts:27
A keyboard event definition that can be used to create a keyboard shortcut.
At least one of key or code must be provided while the alt, ctrl,
meta, and shift modifier configurations are optional.
The key represents a https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
and is treated as case-insensitive.
The code represents a https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
and is treated as case-insensitive.
Type Declaration
Section titled “Type Declaration”
optionalalt?:KeyboardEvent["altKey"]
optionalctrl?:KeyboardEvent["ctrlKey"]
optionalmeta?:KeyboardEvent["metaKey"]
shift?
Section titled “shift?”
optionalshift?:KeyboardEvent["shiftKey"]
Example
Section titled “Example”import type {KeyboardEventDefinition} from '@portabletext/keyboard-shortcuts'
const boldEvent: KeyboardEventDefinition = { key: 'B', alt: false, ctrl: true, meta: false, shift: false,}