How can I access the ^ key with qwertz keyboard-layout

I wrote a script for a simple Console/Terminal.
I want to open the window when I am clicking the ^ key, beneath esc.
It works with other keys, but somehow it won’t recognise the “caret” key.
When I’m changing the keyboard-layout in windows from qwertz to qwerty, everything works perfectly.
But of course that’s not what I want to do all the time.
What can I do?

Any help is appriciated.

Well, on QWERTZ, ^ is Alt Gr + 3, which is a key combination, and I’m not sure key combinations work unless implemented specifically to work that way. If you’re on QWERTZ, I don’t see why you don’t open your terminal with “¸”, as it is a single key press, and relatively exotic, so you’ll neither need it for something in the terminal, nor accidentally press it. Other than that, try to read input as a string, then it won’t look for key presses, so you’ll have a bit less mobility as you’d need to separately implement keycode input if you needed it.

It actually comes in as KeyCode.Backslash at least on my QWERTZ ^^. You can simply test for it with this little snippet:

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

Now whenever you press a button during runtime it will log the keycode as well as the char (if the key has one).

Note that as it has already been mentioned above the carret / circumflex is a combinatory key. So pressing it once will just generate a keydown of “Backslash”. Pressing it again will cause a “Backslash” keydown but also two “^” character key down events.

Likewise when you press an “a” after the first “^” you get a single character “â” if the letter has a combination with the circumflex.

This is actually a common problem with QWERTZ keyboards in most games which use the backslash key as console key. Because opening the console will enter a “^” which can mess up the actual character you type in the console. As a german i’m used to pressing backspace after opening the console ^^.

The actual problem here is that the keycode mapping does not really follow keyboard layouts. Instead it usually uses the QWERTY layout. Although Unity correctly maps “y” and “z”, all other keys just use the QWERTY key names. So for example

"ö" is "BackQuote"
"ä" is "Quote"
"ü" is "Semicolon"
"#" is "Slash"
"ß" is "LeftBracket"
"+" is "Equals"
// strangely the "<" key also returns "Backslash"

In short you can go crazy when even thinking about different keyboard layouts