public AppCommand getCommand(
        KeySequence keys, int editorMode, Map<AppCommand, Boolean> maskedCommands) {
      if (!bindings_.containsKey(keys)) return null;

      List<AppCommandBinding> commands = bindings_.get(keys);
      for (AppCommandBinding binding : commands) {
        int disableModes = binding.getShortcut().getDisableModes();
        AppCommand command = binding.getCommand();

        // If this command is masked by another command, skip it.
        if (maskedCommands != null && maskedCommands.containsKey(command)) continue;

        // Check to see whether this command is enabled for the current
        // editor mode.
        boolean enabled = command.isEnabled() && (disableModes & editorMode) == 0;

        if (enabled) return command;
      }

      return null;
    }
  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;
  }