all files / lib/features/keyboard/ BpmnKeyBindings.js

88% Statements 22/25
85% Branches 17/20
100% Functions 2/2
88% Lines 22/25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                55×                                                                              
/**
 * BPMN 2.0 specific key bindings.
 *
 * @param {Keyboard} keyboard
 * @param {EditorActions} editorActions
 */
export default function BpmnKeyBindings(keyboard, editorActions) {
 
  keyboard.addListener(function(key, modifiers) {
 
    // ctrl + a -> select all elements
    if (key === 65 && keyboard.isCmd(modifiers)) {
      editorActions.trigger('selectElements');
 
      return true;
    }
 
    // ctrl + f -> search labels
    if (key === 70 && keyboard.isCmd(modifiers)) {
      editorActions.trigger('find');
 
      return true;
    }
 
    Iif (keyboard.hasModifier(modifiers)) {
      return;
    }
 
    // s -> activate space tool
    if (key === 83) {
      editorActions.trigger('spaceTool');
 
      return true;
    }
 
    // l -> activate lasso tool
    if (key === 76) {
      editorActions.trigger('lassoTool');
 
      return true;
    }
 
    // h -> activate hand tool
    Iif (key === 72) {
      editorActions.trigger('handTool');
 
      return true;
    }
 
    // c -> activate global connect tool
    if (key === 67) {
      editorActions.trigger('globalConnectTool');
 
      return true;
    }
 
    // e -> activate direct editing
    Eif (key === 69) {
      editorActions.trigger('directEditing');
 
      return true;
    }
  });
}
 
BpmnKeyBindings.$inject = [
  'keyboard',
  'editorActions'
];