SilverBullet uses CodeMirror under the hood, which does the majority of the keyboard handling. In addition, it allows to for customization of (most) keys on a per-command basis. When you open the Command Palette, you will see the currently assigned keyboard shortcut(s).
It is by far the easiest to configure your keyboard shortcuts using the Configuration Manager.
Modifier keys
Your keyboard shortcut will typically consist of a combination of modifier keys as well as a letter or (special) character or number. The following modifier keys are supported:
AltCtrlShiftCmd: Command key (Mac only)Meta: usually the “Windows” keyMod: An alias forCtrlon Linux and Windows, toCmdon Mac
The keyboard shortcut is then combined to e.g. Mod-Alt-t.
Constraints
SilverBullet is constrained in what keyboard can be used in a few ways:
- By the browser: you cannot (usually) override browser keyboard shortcuts, or at least shouldn’t (e.g.
Cmd-torCtrl-tfor opening a new tab) - By already used keyboard shortcuts, see Disabling keyboard shortcuts below to disable keyboard shortcuts for existing commands.
- By CodeMirror’s restrictions. There a few, here are some we know about:
Alt-letteris not allowed (e.g.Alt-a), because it clashes with various (international) keyboards
Combos
Generally keyboard shortcuts are single stroke, however it possible to configure them as “combos” (multiple shortcuts entered in sequence). Out of the box, SilverBullet reserves two prefix keys for this “combo” use:
Mod-.(so “command dot” or Mac and “Ctrl dot” on Linux/Windows), used for various Outlines related commandsCtrl-qused and reserved for Page Template use casesCtrl-q qcreates a ^Library/Std/Page Templates/Quick NoteCtrl-q truns thePage: From Templatecommand
Ctrl-greserved for navigational commands:Ctrl-g hnavigates to the index (home) page
Assigning keyboard shortcuts
Keyboard shortcuts can be assigned to Commands with key or mac. If only key is defined, this keyboard shortcut will be used for all operating systems, if mac is set, this keyboard will be used for macOS.
To (re)assign a keyboard shortcut for an existing command, you can use the ^Library/Std/APIs/Command > command.update(commandDef) API as follows:
command.update {
name = "Task: Cycle State",
key = "Ctrl-Shift-t",
}When you define your own command, you can simply make them part of your command definition:
command.define {
name = "My command",
key = "Ctrl-Shift-t",
run = function()
editor.flashNotification "Hello world "
end
}You can also specify multiple keyboard shortcuts by passing in a table to either key or mac:
command.define {
name = "My command",
key = {"Ctrl-Shift-t", "Ctrl-Shift-o"},
run = function()
editor.flashNotification "Hello world "
end
}Disabling keyboard shortcuts
You can use the ^Library/Std/APIs/Command > command.update(commandDef) API to disable keyboard shortcuts of existing commands by setting them to an empty string, for example:
command.update {
name = "Task: Cycle State",
key = "",
mac = ""
}