title: How to simulate a key press on button click - Unity
body: <p>I'm very new to scripting in Unity, I'm trying to create a button, and once clicked it needs to simulate the 'F' Key being pressed (To pick up an item)</p>
  
  <p>Here is the current code I have, I've looked all over unity forums before writing this but couldn't find anything that worked.</p>
  
  <p>Code:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using System.Collections;
  public class button : MonoBehaviour {
  
      public void ButtonToClick(int clickToButton)
      {
          SendKeys.Send("F");
      }
  } 
  </code></pre>