play music on key press

I want to play a sound when I pressed number 1 key on the keyboard, how do I do it?

Try the following script on the gameObject that has the Audio Source. Look at the inspector window and you will see an inspector variable in the script. Here you can select “Alpha1” for the number 1 key. You can add the Alpha1 into the code to but having an inspector variable gives you control over the key input incase you wanted to add more sounds played by different keys.

 var keyBoardSound : KeyCode;	
    
    function Update () 
    {
    	if(Input.GetKeyDown(keyBoardSound))
    	{
    		audio.Play();
    	}
    
    }