How can i bind Prefab for a Keyinput?

Hello , I’m trying to make a typing game ( like guitar hero but with letter from the keyboard)
I’ve made sprites representing each Letter ( say A has a sprite A )
i made a spawner and for each letter i made a fly script that makes the Letter fly towards our hero.
Now i put an aiming point to which when the Prefab( A ) hits the Aim and you press A on the keyboard . the Prefab gets destroyed and gives me a score…
here is my script

public class fly : MonoBehaviour {
score sc;
	public Rigidbody2D flyingobj;
	public float speed = -7f;
		
	// Use this for initialization


	void OnTriggerStay2D(Collider2D other)
	{
		if (other.tag == "aim" && Input.GetKeyDown(KeyCode.A)) 
		{
			sc = GameObject.Find("MainCamera").GetComponent<score>();
			sc.IncreaseScore(2);
			Destroy(this.gameObject);
		}
	}
	void Start () 
	
	
	{
		// Set the prop's velocity to this speed in the x axis.
		flyingobj.velocity = new Vector2(speed, 0);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

okay now the problem is that I have 26 letters … that means i have to make a script for each letter … is there a way to make a generic script and then for each prefab bind it to a key input?
like say

{ 
if (other.tag == "aim" && Input.GetKeyDown(KeyCode.(generic)))
} 

and generic is A in the A prefab…
[I know that this code is wrong , i’m just trying to explain myself]

Or is there an easier way to do this?
Thank you for your time!
PS : if you haven’t noticed already I’m a beginner in Unity and scripting all together I’m learning as i go

Simplest thing to do might be to make a public variable and use that as the key code. Then go through your prefabs and set the variable through the editor for each letter.

Assuming you’re trying it with KeyBoard Inputs,

Public bool triggeredWithAim = false;

void Update()
{
if(Input.GetKey(KeyCode.A))
{
if(triggeredWithAim)
{
//Key Board Pressing A.
//Destroy This (A) object.
}
}
}

Void OnTriggerEnter(Collider obj)
{
if(obj.gameObject.tag == "aim")
{
//triggered with aim
this.triggeredWithAim = true;
}
}

Better you may save all keycodes in a list then use switch case on Update.

Do this:

class Whatever {
public KeyCode key;

void SomeFunction() {
if (Input.GetKeyDown(key))
DoSomething();
}
}

Enums are data types, and can be declared publicly and assigned values in Unity Editor; it’s done rather cleverly as the Editor automatically shows you the names of the enum’s members instead of their numeric values. They can also be stored in variables and accessed without explicitly specifying their name. Thinking enums (such as KeyCode) can only be accessed by name is a rather common mistake.