I am working on a 2D game in Unity and one of the control schemes for the game involves holding down the left control key to start crouching and then when A or D is pressed the character begins to move. The problem is when using the A and D keys in addition to holding control, the character doesn’t move. However, it does seem to work while using the arrows keys left and right. Any advice or tricks to fix this?
I don’t think that’s ghosting. CTRL is a pure combination key, so pressing it together with another key is how it’s ment to be used.
The problem is that are all hotkeys which are recognised by the Unity Editor itself. In a build it will work as expected. For testing i recommend to not use the CTRL key in the editor. You can setup another alternate key for crouching. Try press CTRL and S and you will actually get a notification that you can’t save the scene while in run-mode.
CTRL + D is "duplicate" in the editor
CTRL + A is "select all"
Unity uses a lot CTRL key ombinations. So avoid modifier keys (CTRL / ALT) completely if possible.
Again: In a build all those problems are gone.
This may be an issue with Keyboard Ghosting, this can be specific to your hardware.
You should go read about it as Microsoft covers this well here as well as a demo to see if your current keyboard is affected by ghosting.
This would be the case if you are strictly moving your character when using the if statements for Keycode.A and D. You should rather have these if statement assign movement modifier. Then on a LateUpdate depending after input, take the modified movement and apply that to your movement function. This way it accounts for all movements based on input.