How to make Karabiner work with Intellij on Mac?

I've recently switched from Windows/Ubuntu to MacOS Catalina and I'm trying to avoid changing too many key mappings on Intellij 2020.2.

I'm trying to achieve these things:

  1. Swap Left Ctrl and Fn
  2. Having function keys as default in touch bar when using Intellij to be able to use combinations like Ctrl + F4 in Intellij without having to press any additional (Fn) keys
  3. (If possible) Map Ctrl + click to something other than Right Click

Here's what I've done so far:

  1. Swap Left Ctrl and Fn using Karabiner
  2. System Preferences > Keyboard > Shortcuts > Function Keys > Add Intellij
  3. Imported a complex modification in Karabiner to change Ctrl + click to just click.

The issues that I'm facing:

  1. Pressing original Fn (mapped to Left Ctrl) in Intellij changes touch bar from Function keys to other touch bar options. I'd like to disable this to be able to use Ctrl+F4.
  2. Left Ctrl+Click still behaves as right click.

You can edit the Karabiner rules to ignore IntelliJ completely, then, you can use IntelliJ's keymaps to change keys as you want.

You can also create your own rules in Karabiner to remap keys for IntelliJ if you want.

The Karabiner config file is located in ~/.config/karabiner/karabiner.json, and editing it is not to complex, you can use comparators like frontmost_application_unless and frontmost_application_if to select which app the keymap applies to.

What I did was to import some predefined keymaps to understand the file format, and use them as examples for modifying the ones I was interested in.

For example, for Ctrl+C it was this, so you can adapt it for your needs:

{
  "description": "Copy Command (Except IntelliJ IDEs)",
  "manipulators": [
    {
      "conditions": [
        {
          "bundle_identifiers": [
            "^com\\.jetbrains\\..*$"
          ],
          "type": "frontmost_application_unless"
        }
      ],
      "from": {
        "key_code": "c",
        "modifiers": {
          "mandatory": [
            "control"
          ],
          "optional": [
            "any"
          ]
        }
      },
      "to": [
        {
          "key_code": "c",
          "modifiers": [
            "left_command"
          ]
        }
      ],
      "type": "basic"
    }
  ]
}