Shortcuts
Shortcuts or hotkeys are combination of computer keyboard keys that allow users to perform actions and operations quickly without having to use the mouse or touchpad.
Usage #
You can add the shortcut ability to your editor with the help of contenido
's utilities.
To have shortcut enabled in your editor you have to provide to functions. The first one
helps editor to bind the key combinations and the second one will translate that combination
to a meaningful editor action.
NOTE: The default value provided as shortcut map for the following utilities only supports
BOLD
, ITALIC
, UNDERLINE
and SOFT_NEWLINE
. If you need a complete shortcut support
pass the shortcutMap
to as the customShortcuts
. There is a default list of key combination
provided by contenido
and you can check it here.
getDefaultKeyBindingFn #
The getDefaultKeyBindingFn
utility helps you to bind key combinations.
shortcutHandler #
The shortcutHandler
utility will handle the action returned by getDefaultKeyBindingFn
and
updates the editor state.
Example #
An example of shortcuts usage:
Customization #
You can create a custom shortcut map of ShortcutMap
type and then pass it as a new shortcut
to the default one.
This is BOLD
style shortcut object as an example:
The ctrl
, control
, cmd
, command
, 'shift', 'alt' and 'option' keywords are meaningful
for the handler. You can also write your own function as shortcut handler.
Here is an example of shortcuts customization: