unity get key from string
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class Lifes : MonoBehaviour
{
public string CustomKey;
// Start is called before the first frame update
void Start()
{
// Check if the key is uppercase - if so then "CustomKey" will be changed to lowercase.
// Check https://docs.unity3d.com/Manual/class-InputManager.html for the key families.
if(CustomKey.Any(char.IsUpper))
{
CustomKey = CustomKey.ToLower();
}
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(CustomKey))
{
Debug.Log(CustomKey + " got pressed.");
}
}
}