private boolean dispatch(
      KeyboardShortcut shortcut,
      AppCommandBindings bindings,
      NativeEvent event,
      Map<AppCommand, Boolean> maskedCommandsMap) {
    KeySequence keys = shortcut.getKeySequence();

    // If the shortcut manager is disabled, bail
    if (!isEnabled()) return false;

    // If we have no binding, bail
    if (!bindings.containsKey(keys)) return false;

    AppCommand command = bindings.getCommand(keys, editorMode_, maskedCommandsMap);
    if (command == null) return false;

    event.preventDefault();
    command.executeFromShortcut();
    return true;
  }
  private boolean dispatch(
      KeyboardShortcut shortcut,
      Map<KeyboardShortcut, ArrayList<AppCommand>> bindings,
      NativeEvent event,
      Map<AppCommand, Boolean> maskedCommandsMap) {
    if (!bindings.containsKey(shortcut) || bindings.get(shortcut) == null) return false;

    AppCommand command = null;
    for (int i = 0; i < bindings.get(shortcut).size(); i++) {
      command = bindings.get(shortcut).get(i);
      if (command != null) {
        boolean enabled = isEnabled() && command.isEnabled();

        // some commands want their keyboard shortcut to pass through
        // to the browser when they are disabled (e.g. Cmd+W)
        if (!enabled && !command.preventShortcutWhenDisabled()) return false;

        // if we've remapped an AppCommand to a new binding, it's
        // implicitly disabled
        if (maskedCommandsMap != null && maskedCommandsMap.containsKey(command)) {
          command = null;
          continue;
        }

        event.preventDefault();

        // if this command is enabled, execute it and stop looking
        if (enabled) {
          command.executeFromShortcut();
          break;
        }
      }
    }

    return command != null;
  }