Some keys aren't registered in KeyCode

I have a script that detects when keys are pressed for a typing sound program. But when I press the tilde, left curly bracket, right curly bracket, or the colon key, it doesn’t pick up that I actually pressed it.

if (Input.GetKeyDown(KeyCode.Tilde))
            int index = Random.Range(0, keyClicks.Length);
            keyClickClip = keyClicks[index];
            _as.clip = keyClickClip;
            tildeKey.GetComponent<SpriteRenderer>().color = new Color(100f, 100f, 100f, 100f);

The KeyCode enum represents virtual key codes any depends on your keyboard layout. I have a german “qwertz” keyboard and do not have a dedicated “tilde” key. On my keyboard it’s on the + / * key to the left of the return key but I need to hold the “AltGr” key.

What you can do is this:

void OnGUI()
    Event e = Event.current;
    if (e.type == EventType.KeyDown)
        Debug.Log("KeyDown: " + e.keyCode);

When you run that code you will see which key is actually mapped to a certain key when you press it.