any workaround of broken keycode detection on linux
I use the following code to detect currently pressed keyboard or mouse button. works flawessly for windows, but is broken on linux in non-english locales and always returns keycode.none for non-english letters. Any fix?
public class NewBehaviourScript : MonoBehaviour {
public Text textTesterLinux;
void KK()
{
if (textTesterLinux == null) { return; }
var pressedKeyCode = KeyCode.None;
if (Input.anyKeyDown)
{
pressedKeyCode = FetchKey();
if (pressedKeyCode != KeyCode.None)
{
textTesterLinux.text = "keycode " + "{" + pressedKeyCode + "}" + " keycodeCODE " + "{" + (int)pressedKeyCode + "}";
}
}
}
KeyCode FetchKey()
{
foreach (KeyCode kk in Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKeyDown(kk))
{
return kk;
}
}
return KeyCode.None;
}
void Update () {
KK();
}
}
Comment
Hello. I have the same problem. Did you find a solution or understand the reason?
Your answer
![](https://koobas.hobune.stream/wayback/20220612110218im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Joystick 3rd Axis problem on Linux 0 Answers
Space bar input not recognized 3 Answers
Linux Full screen input doesn't work 0 Answers
DeadZone in the corner of a xBox controller 0 Answers
Jump Input Problem 0 Answers