Custom Keybinds - slugcat-dev/mark-ed GitHub Wiki
The keymap object defines custom keybinds, where each keybind is mapped to a handler. The property name defines the key combination, and the value is the function that will be executed when that key combination is pressed.
Key modifiers:
CtrlShiftAltMetaCtrlMeta(Ctrlon Windows and Linux,Metaon MacOS)CtrlAlt(Ctrlon Windows and Linux,Alton MacOS)
Most keybinds work like this: First modify the content, then adjust the selection to the new content. The following code adds a keybind for basic bold formatting. A more complete version would also wrap selected text with asterisks instead of replacing it.
keymap: {
'CtrlMeta B': editor => {
// Insert bold formatting
editor.insertAtSelection('**bold**')
// Select the word "bold"
editor.setSelection({
start: editor.selection.start - 6,
end: editor.selection.start - 2
})
}
}