[macOS, C#] How to filter out Ctrl + LMB becoming RMB when using Input.IsActionJustPressed() for LMB while also holding Ctrl?

Godot Version

4.6.2

Question

I am currently porting some of my first-person 3D game code base from Unity to Godot while doing all the work on a macOS system. The ported code is using Godot’s Input Map for: “Crouching” action (linked to Ctrl), “Action” action (linked to Left Mouse Button), and “Throw“ action (linked to Right Mouse Button).

In Unity on macOS, while using this code base, I’ve always been getting both inputs for “Crouching“ and “Action“ when both Ctrl and LMB were being pressed — just like it would behave on Windows. And in Godot, when using the same logic with Input Map, the engine doesn’t filter out the classic “LMB + Ctrl = RMB“ conversion of macOS systems, so I’m getting a “Throw“ input instead when crouching and pressing “Action“ (LMB) in my game.

My project is cross-platform, includes a Key Rebinding menu, and, in addition to that, “Ctrl“ in Godot Input Map means the same Ctrl key both on macOS, and Windows, and Linux — so, completely avoiding “Ctrl“ on macOS specifically, by manually replacing it in code with “Cmd“, will be a very unpleasant solution (what if a macOS player rebinds the Crouching action back to “Ctrl“?)

There has to be a fix for this behaviour, right?

  1. Crouching + pressing left mouse button to shoot — is a classic formula for computer FPS games, so some developer must have found the solution for this at some point.
  2. This Godot bug report from 2017 suggests that (at least) the editor at some point was able to ignore the Ctrl + LMB = RMB conversion, so it’s not something that is impossible to avoid on macOS.

Just checked: Input.GetMouseButtonMask() also can’t see LMB pressed while holding Ctrl on macOS — it returns “Right” (2).

Which of these options have you tried for your mapped Ctrl key?

My initial option for Ctrl:

  • Physical Keycode (Position on US QWERTY Keyboard) - Physical Location Unspecified

Just tested and had the same results:

  • Physical Keycode (Position on US QWERTY Keyboard) - Physical Location Left
  • Keycode (Latin Equivalent)
  • Key Label (Unicode, Case-Insensitive)

I stopped using Ctrl as a keyboard key because I do a lot of web games, and Ctrl + W gets caught by the browser and closes the window.

The real problem is that Godot is not consuming the signal for the entire OS. If it did that, there would be no problem. I don’t know if there’s a solution for that.