How to press button on keyboard by C# Script?

How to press button on keyboard by code?

void Update()
{
if (Input.GetKeyDown(KeyCode.H)) //When H is pressed
{
(your code)
}
}
you can replace GetKeyDown with GetKeyUp OR Just GetKey.
GetKey is when the button is held down.