Skip to main content

Keyboard Shortcuts

Windoc supports registering custom keyboard shortcuts via the editor instance.

Registering Shortcuts

Use editor.register.shortcutList() after the editor is ready:

import { Editor } from '@windoc/react'

function App() {
return (
<Editor
onReady={(editor) => {
const { KeyMap } = require('@windoc/core')

editor.register.shortcutList([
{
key: KeyMap.P,
mod: true, // Cmd on Mac, Ctrl on Windows
isGlobal: true,
callback: (command) => {
command.executePrint()
},
},
{
key: KeyMap.MINUS,
ctrl: true,
isGlobal: true,
callback: (command) => {
command.executePageScaleMinus()
},
},
{
key: KeyMap.EQUAL,
ctrl: true,
isGlobal: true,
callback: (command) => {
command.executePageScaleAdd()
},
},
])
}}
/>
)
}

Shortcut Options

PropertyTypeDescription
keyKeyMapThe key to bind
modbooleanCmd (Mac) / Ctrl (Windows)
ctrlbooleanCtrl key specifically
shiftbooleanShift key
altbooleanAlt/Option key
isGlobalbooleanWhether shortcut works outside editor focus
callback(command) => voidHandler receiving the command API

Built-in Shortcuts

The editor comes with these shortcuts out of the box:

ShortcutAction
Ctrl/Cmd + ZUndo
Ctrl/Cmd + Shift + ZRedo
Ctrl/Cmd + BBold
Ctrl/Cmd + IItalic
Ctrl/Cmd + UUnderline
Ctrl/Cmd + CCopy
Ctrl/Cmd + VPaste
Ctrl/Cmd + XCut
Ctrl/Cmd + ASelect all
TabIndent / next cell
Shift + TabOutdent / previous cell