Fix #538. Update action registration with key chord.

pull/582/head
rebornix 2017-08-09 14:25:59 -07:00
parent 77b9f571f6
commit 8ef75ad01c
2 changed files with 12 additions and 2 deletions

View File

@ -53,6 +53,7 @@ var editor = monaco.editor.create(document.getElementById("container"), {
// Explanation: // Explanation:
// Press F1 (Alt-F1 in IE) => the action will appear and run if it is enabled // Press F1 (Alt-F1 in IE) => the action will appear and run if it is enabled
// Press Ctrl-F10 => the action will run if it is enabled // Press Ctrl-F10 => the action will run if it is enabled
// Press Chord Ctrl-K, Ctrl-M => the action will run if it is enabled
editor.addAction({ editor.addAction({
// An unique identifier of the contributed action. // An unique identifier of the contributed action.
@ -62,7 +63,11 @@ editor.addAction({
label: 'My Label!!!', label: 'My Label!!!',
// An optional array of keybindings for the action. // An optional array of keybindings for the action.
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10], keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10,
// chord
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_M)
],
// A precondition for this action. // A precondition for this action.
precondition: null, precondition: null,

View File

@ -15,6 +15,7 @@ var editor = monaco.editor.create(document.getElementById("container"), {
// Explanation: // Explanation:
// Press F1 (Alt-F1 in IE) => the action will appear and run if it is enabled // Press F1 (Alt-F1 in IE) => the action will appear and run if it is enabled
// Press Ctrl-F10 => the action will run if it is enabled // Press Ctrl-F10 => the action will run if it is enabled
// Press Chord Ctrl-K, Ctrl-M => the action will run if it is enabled
editor.addAction({ editor.addAction({
// An unique identifier of the contributed action. // An unique identifier of the contributed action.
@ -24,7 +25,11 @@ editor.addAction({
label: 'My Label!!!', label: 'My Label!!!',
// An optional array of keybindings for the action. // An optional array of keybindings for the action.
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10], keybindings: [
monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10,
// chord
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_M)
],
// A precondition for this action. // A precondition for this action.
precondition: null, precondition: null,