How do I make a UI button to click a key?

What I mean is that when I click a UI button it should click a key on my keyboard. I dont know how I do that. Im pretty new to Unity so. How do I do that?

You’ve not really given us much to go on but at least you’ve made decent attempt at tags so I’m going to assume you mean the new UI, that you want Text on Screen to be displayed when you click a button.

Could be lots of other things you’re trying but that’s what I’m working towards at the moment.

I’ve got a very basic input script for a keyboard. You attach it to the canvas. You also have a Text object on your canvas to receive the text. It also handles backspace and shift.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class MyKeyboard : MonoBehaviour {

	private bool shiftOn = false;
	public Text MyText;
	public Image ShiftImage;

	public void KeyClicked(string whichKey)
	{
		if (shiftOn)
			MyText.text = MyText.text + whichKey.ToUpper ();
		else
			MyText.text = MyText.text + whichKey;
	}

	public void BackClicked()
	{
		if (MyText.text.Length > 0)
			MyText.text = MyText.text.Substring (0, MyText.text.Length - 1);
	}

	public void ShiftClicked()
	{
		shiftOn = !shiftOn;
		if (shiftOn)
			ShiftImage.color = Color.gray;
		else
			ShiftImage.color = Color.white;
	}
}

Put that on your canvas and add the buttons you want, drag the Text onto the public Text Slot and The shift button onto the ShiftImage slot.

Then for each button you add an onClick, drag the canvas onto the slot that appears and from the dropdown select MyKeyboard → KeyClicked. As that function receives a string a box will appear so for the a key button put a in that box.

You can also set the backspace to call BackClicked and Shift to call ShiftClicked.