Control Key Changing Keycode?

Hi,

I was running some code from an older project in 2018.2 when I noticed something with the input logic that has stopped working. Basically I toggle some debug UI overlay based on the user / developer pressing CTRL+F but that has stopped working. To verify my logic I wrote this simple test script (in a MonoBehaviour Update function):

bool controlHeld = (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl));
bool toggleKeyHeld = Input.GetKey(KeyCode.F);

Debug.Log("CTRL = " + (controlHeld ? "TRUE" : "FALSE") + " ,F = " + (toggleKeyHeld ? "TRUE" : "FALSE"));

When I test it I get the following result (just using the left control button to limit the complexity):
When I do not hold down anything: CTRL = FALSE ,F = FALSE
When I hold down Control only: CTRL = TRUE ,F = FALSE
When I hold down F only: CTRL = FALSE ,F = TRUE
When I hold down Control first and then hold down F as well: CTRL = TRUE, F = FALSE
When I hold down F first and then hold down Control as well: CTRL = TRUE ,F = TRUE

Based on these results it seems that holding down CTRL changes the keycode that the game receives, so it no longer receives Input.GetKey(KeyCode.F) as true. Is this intended behaviour? If so, what is the correct/better way to do this (this is just for debug functionality)?

Cheers,
Ron

This looks like a 2018 bug.
I’m using 2017 and your code worked fine for me.

To work around it try using Event.KeyboardEvent.
Also make sure to test this in another machine/keyboard as it could be a local issue.

Hi Fernando, thanks for the tip. Unfortunately that approach seems to suffer from the same issue.

Once I have fully moved the project to 2018.2 I’ll try it on different machines to check whether it is something local.

Is this in built game as well as editor?
I’ve experienced that sometimes the editor will steal input if that particular key binding is in one of the unity menus.