cmd-tab returns 'A' key press on macOS

So, ever since moving completely to the new Input System, I’ve been having a bug where my player will immediately move left if I cmd-tab to focus out of unity (or a build I make) and focus back on it. I checked my code and my input system bindings, and there’s no code that checks for the cmd key or the tab key. After looking online to see if anyone else has had the same issue, I came across some people on another forum post ( Input System bugs ) where @martt_1er had the same issue. Apparently if I cmd-tab and focus back onto Unity or a build I make, it registers it as an A key input, which moves the player left. Pressing it on the keyboard fixes the problem, but it’s a major nuisance nonetheless. Doing cmd-shift-4 which is used for taking screenshots also yields the same result. I was only able to find mention of this bug on the aforementioned forum post so I felt I should make a post specifically about the issue to see if there’s a way to get around this, or if a fix is being made.

I’m on macOS Mojave ver. 10.14.6, and I’m using Unity 2019.2.15f1 with Input System 1.0.0 (US keyboard as well if that’s important).

Let me know if there’s any other information that I should provide.

I just discovered the same issue and a couple searches brought up your post.

After a cmd-tab to focus back on Unity, Keyboard.current.aKey.isPressed returns true until the ‘a’ key is actually pressed.

This is Unity 2020.1.6f1 on (unsupported) Mac OS 10.12.6 (Sierra) with Input System 1.0.0.

I’m getting the exact same issue when doing cmd-shift-4 for screenshots. It registers that the a Key is pressed and that the shift key is pressed as well, and it remains stuck.

Unity 2019.4.1f1, InputSystem 1.0.0, Mac OS Catalina 10.15.7

Same issue on my end. I’m on -

Unity 2019.4.11f1, InputSystem 1.0.0, Mac OS Catalina 10.15.7

I’ve logged a bug with Unity but also found this issue (Unity Issue Tracker - [Input System][macOS] Keyboard button A is triggered when taking a screenshot with built-in tools) already being tracked.

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/changelog/CHANGELOG.html
^ This is the change log of Input System 1.0.0 which mentions that they fixed it but the issue still persists on Macs.

I’m actively finding a fix or a workaround. I’ll post the solution if I find it!

Some good news. I found a workaround for the bug.

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
            if (Keyboard.current.aKey.isPressed && Keyboard.current.leftMetaKey.isPressed)
            {
                InputSystem.TryResetDevice(Keyboard.current);
                return;
            }
#endif

Everytime Cmd + Tab or Cmd + Shft + 4 or a similar command is executed, on Macs the app doesn’t lose focus and the Input System registers erroneous inputs for the A Key and LeftMeta Key. The above hack ignores the input combination and resets the keyboard.

Unfortunately this hasn’t fixed the problem for me :(. Not sure why since the logic seems sound. Silly question I imagine, but does OSX also include OSs that were rebranded as macOS and not OSX?

Okay, so this does fix the CMD SHIFT 4 command, but it does not fix the CMD + Tab command unfortunately. I’m trying to see what input is being pressed that’s causing the issue, but I’m just getting nothing.

do you have a link to this issue on the issuetracker?