This key function isn't working as expected...

Basically, I have a key binding section of my options menu. When you click the edit button next to one of the binding it brings up a window that checks for any key press. It works great for letters and alpha nums. However, it does not work for the F keys, or the numpad. is there any reason for this?

My Function:

private KeyCode FetchKey()
{

	int e = System.Enum.GetNames(typeof(KeyCode)).Length;
	for(int i = 0; i < e; i++)
	{
		if(Input.GetKey((KeyCode)i))
		{
			return (KeyCode)i;
		}
	}
	
	return KeyCode.None;
}

Thanks
Tom

Got it. Integrate this:

using UnityEngine;

public class Tasdf : MonoBehaviour
{
    private string[] m_keys;

    private void Awake()
    {
        m_keys = System.Enum.GetNames(typeof(KeyCode));
        foreach (var key in m_keys)
        {
            Debug.Log(key);
        }
    }

	// Update is called once per frame
	void Update ()
    {
        if (Input.anyKeyDown)
        {
            foreach (var key in m_keys)
            {
                if (Input.GetKey((KeyCode) System.Enum.Parse(typeof(KeyCode), key)))
                {
                    Debug.Log(key + " was pressed");
                }
            }
        }
	}
}