How to customize shortcuts
Glamorous Toolkit organizes all keyboard shortcuts through a central keymap registry. Each shortcut has a unique identifier and a default key combination stored in the registry. Any shortcut's key binding can be changed without modifying source code, or restarting tools. Key combinations are resolved at runtime based on a shortcut's id.
Shortcuts are grouped into registries, each responsible for a different area of the system.
Some of the main registers are:
- Editor (BrEditorKeymapRegistry
) — text editing: cursor movement, selection, copy/paste, undo/redo.
- Lepiter (LeKeymapRegistry
) — snippet management: move, indent, split, delete.
- Coder (GtCoderKeymapRegistry
) — source code: evaluate, browse, format, debug.
- Space (BlSpaceKeymapRegistry
) — window-level: zoom, screenshot, tabs, spotter.
- Debugger (GtDebuggerKeymapRegistry
) — debugger actions: step over/into/through, resume, restart.
You can inspect the full registry and all its current bindings:
BlShortcutKeymapRegistry default
It is also possible to inspect individual registries.
BlShortcutKeymapRegistry default coder
To change a shortcut, send BlShortcutKeymapRegistryCategory>>#updateShortcutFor:with:
to the appropriate registry with the shortcut id and the new key combination.
The change takes effect immediately for all shortcuts that reference that id.
Changing the "Evaluate and inspect" coder shortcut from Ctrl+G to Ctrl+Shift+I:
BlShortcutKeymapRegistry default coder updateShortcutFor: GtCoderShortcutIds default doItAndInspectShortcutId with: (BlKeyCombination builder primary shift i build)
Changing a shortcut in the editor (e.g., "Select All" from Ctrl+A to Ctrl+Shift+A):
BlShortcutKeymapRegistry default editor updateShortcutFor: BrEditorShortcutIds default selectAllShortcutId with: (BlKeyCombination builder primary shift a build)
Changing a Lepiter snippet shortcut (e.g., "Move snippet up" to Alt+Up):
BlShortcutKeymapRegistry default lepiter updateShortcutFor: LeShortcutIds default moveSnippetUpShortcutId with: (BlKeyCombination builder alt arrowUp build)
Changing a debugger shortcut (e.g., "Step Over" from F10 to Ctrl+Shift+O):
BlShortcutKeymapRegistry default debugger updateShortcutFor: GtDebuggerShortcutIds default stepOverShortcutId with: (BlKeyCombination builder primary shift o build)
To reset all shortcuts back to their defaults:
BlShortcutKeymapRegistry reset
This reinitializes all registries from scratch, restoring every shortcut to its default combination.
For a deeper understanding of how the shortcut system is implemented, see Shortcuts and the keymap registry.