Keyboard Ctrl + 1 Input Problem

Is there a way to handle grouping keyboard inputs like Ctrl+[numeric]? Example: Ctrl+1, Ctrl+2, etc.

I’ve tried the following:

if(Input.GetKey("left ctrl"){
     if(Input.GetKeyDown("1"){
          Debug.Log("Ctrl+1 Down");
     }
}

If I change the “left ctrl” to a “left alt” then there aren’t any problems, otherwise it seems like Control is blocking access to the other characaters.

Alt is already bound to another action so it’d be really nice if I could use Ctrl.

It is a very simple and logical solution and that is why it was a problem. ( The easy ones always cause the most problems!)

if(Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.S))

{
// Do what ever you need
}

In your case use KeyCode.Alpha1

I found that this will NOT work in the unity editor because CTRL is used for other things within the editor. However, when you build and run your application it will work just as expected.

I hope this helps!

Try using Input.GetKeyDown(KeyCode.LeftControl) instead.

Your syntax is incorrect…

if(Input.GetKey("left ctrl")){
     if(Input.GetKeyDown("1")){
          Debug.Log("Ctrl+1 Down");
     }
}