Checking whether string is a valid Input.Key

Hi,
lets say I have a string X which should be used as Input.KeyUp(x). however, it will change during runtime and it may contain a string that its not a “valid” key string so it would throw an exception. can I somehow check whether the string X is a valid key? (so I could ignore if its not)

ok I already figured it out: (the catch part will happen only if it fails)

try
		{
			Input.GetKey(key);
		}
		catch
		{
			Debug.Log("aaa");
		}