- Home /
Is it possible to have hotkeys for characters like å, ä, ö?
I currently have a hotkey system working great for standard characters, like QWERTY.
However, some players would prefer hotkeys for characters like å, ä, ö, etc.
Is it possible to support this in Unity?
Answer by Quatum1000 · Aug 20, 2017 at 06:59 PM
Thanks to eskivor for this little script. On a german layout the following special keys are mapped.
KeyCode.Quote = ä
KeyCode.BackQuote = ö
KeyCode.Semicolon = ü
KeyCode.Slash = #
KeyCode.Equals = +
KeyCode.RightBracket = ´
KeyCode.LeftBracket = ß
The only issue happen on ^ and < they always respond KeyCode.Backslash
All other work as expected.
Answer by eskivor · Jun 14, 2017 at 03:23 PM
You can find here the list of all keyboard characters recognized by Unity : https://docs.unity3d.com/ScriptReference/KeyCode.html
For special characters it can work, but you have to find first what is the equivalent key in QWERTY, for example the key "ù" in AZERTY correspond to "`" (BackQuote) in QWERTY.
To find which one it is : in the editor, in a project, you can add a script on a object of your scene and tap the key you want (å, ä, ö, etc.) it will print the QWERTY equivalent.
using UnityEngine;
using System;
public class FindMyKeyInQwerty : MonoBehaviour
{
void Update ()
{
foreach (KeyCode keycode in Enum.GetValues (typeof (KeyCode)))
{
if (Input.GetKeyDown (keycode))
{
Debug.Log ("Qwerty key is : " + keycode );
}
}
}
}
Answer by Z_Lokke · Jun 14, 2017 at 03:23 PM
I'll admit that I'm not 100% on this, but I don't believe these individual characters are supported in the Unity KeyCode API, which is found here:
https://docs.unity3d.com/ScriptReference/KeyCode.html
However, if these keys are found on your keyboard they may be coming through as inputs either way. Basically, since all keys correlate to a number received from the keyboard (like maybe a = 1 on a QWERTY keyboard), these special characters may be coming across as a different key. AKA, a character input like ö on a different keyboard format may be input using the same KeyCode as F, so when the user presses the special character the engine recognizes an F input. You could run a check to see if this is happening and try to line up your inputs appropriately. It could take a little bit and its definitely a work around, but worth a try.
Just a thought.
~Z
Your answer
Follow this Question
Related Questions
Stimulate key press via a GUITexture 0 Answers
How to make a sprite fade in when I hit space? 0 Answers
GUI.Button's status react to keyboard event? 0 Answers
Forcing GetKeyDown by script. 2 Answers
Keyboard Input with a textbox 1 Answer