in src/vs/workbench/contrib/preferences/browser/preferences.contribution.ts [875:1023]
private registerKeybindingEditorActions(): void {
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_DEFINE,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K),
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.defineKeybinding(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_DEFINE_WHEN,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_E),
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor && editorPane.activeKeybindingEntry!.keybindingItem.keybinding) {
editorPane.defineWhenExpression(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_REMOVE,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: KeyCode.Delete,
mac: {
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.Backspace)
},
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.removeKeybinding(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_RESET,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: 0,
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.resetKeybinding(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_SEARCH,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR),
primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.focusSearch();
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_RECORD_SEARCH_KEYS,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS),
primary: KeyMod.Alt | KeyCode.KEY_K,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_K },
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.recordSearchKeys();
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_SORTBY_PRECEDENCE,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR),
primary: KeyMod.Alt | KeyCode.KEY_P,
mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_P },
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.toggleSortByPrecedence();
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: 0,
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.showSimilarKeybindings(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_COPY,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
handler: async (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
await editorPane.copyKeybinding(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDING_FOCUS),
primary: 0,
handler: async (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
await editorPane.copyKeybindingCommand(editorPane.activeKeybindingEntry!);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS),
primary: KeyCode.DownArrow,
handler: (accessor, args: any) => {
const editorPane = accessor.get(IEditorService).activeEditorPane;
if (editorPane instanceof KeybindingsEditor) {
editorPane.focusKeybindings();
}
}
});
}