unity detect number key

C#
// Replace the 1 with your number
if (Input.GetKeyDown(KeyCode.Alpha1)) {
  //Code here
}
Source

Also in C#: