Keypad Enter in the input manager
Hello!
I'm trying to use keypad enter as a key in the input manager.
Judging from this, page: https://docs.unity3d.com/Manual/ConventionalGameInput.html Keypad enter should be “[equals]”, however that does not work.
The page also says: "The names used to identify the keys are the same in the scripting interface and the Inspector."
That is not true, the names are completely different. "KeypadReturn" does not exist and for all other keypad keys it is completely different.
Lower on the page it says: "Note also that the keys are accessible using the KeyCode enum parameter."
That is also not true, the enum contains key codes that does not work in the input manager.
Why is it so misleading in every possible way? Why is there not a list of possible values to be found anywhere?
Answer by omni_angel7 · Sep 01, 2017 at 08:23 AM
Hey there! After much frustration, I was able to compile the list you seek. Attached and copied below is some c# code that should help you out.
using UnityEngine;
public static class UnityKeyCodeNames
{
public static KeyCode GetKeyCodeFromName(string s)
{
if (!string.IsNullOrEmpty(s) && !string.IsNullOrEmpty(s = s.Trim()))
{
var idx = System.Array.IndexOf(Names, s);
if (idx >= 0)
{
return (KeyCode)idx;
}
}
return KeyCode.None;
}
public static string GetNameFromKeyCode(KeyCode keycode)
{
return Names[(int)keycode];
}
/// <summary>
/// This array directly aligns with the UnityEngine.KeyCode enum. Values not present in the enum are represented here with "" (string.Empty).
/// </summary>
public static readonly string[] Names = new[]
{
"", // Keycode.None
"",
"",
"",
"",
"",
"",
"",
"backspace",
"tab",
"",
"",
"clear",
"return",
"",
"",
"",
"",
"",
"pause",
"",
"",
"",
"",
"",
"",
"",
"escape",
"",
"",
"",
"",
"space",
"!",
"\"",
"#",
"$",
"",
"&",
"'",
"(",
")",
"*",
"+",
",",
"-",
".",
"/",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
":",
";",
"<",
"=",
">",
"?",
"@",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"[",
"\\",
"]",
"^",
"_",
"`",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"",
"",
"",
"",
"delete",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"world 0",
"world 1",
"world 2",
"world 3",
"world 4",
"world 5",
"world 6",
"world 7",
"world 8",
"world 9",
"world 10",
"world 11",
"world 12",
"world 13",
"world 14",
"world 15",
"world 16",
"world 17",
"world 18",
"world 19",
"world 20",
"world 21",
"world 22",
"world 23",
"world 24",
"world 25",
"world 26",
"world 27",
"world 28",
"world 29",
"world 30",
"world 31",
"world 32",
"world 33",
"world 34",
"world 35",
"world 36",
"world 37",
"world 38",
"world 39",
"world 40",
"world 41",
"world 42",
"world 43",
"world 44",
"world 45",
"world 46",
"world 47",
"world 48",
"world 49",
"world 50",
"world 51",
"world 52",
"world 53",
"world 54",
"world 55",
"world 56",
"world 57",
"world 58",
"world 59",
"world 60",
"world 61",
"world 62",
"world 63",
"world 64",
"world 65",
"world 66",
"world 67",
"world 68",
"world 69",
"world 70",
"world 71",
"world 72",
"world 73",
"world 74",
"world 75",
"world 76",
"world 77",
"world 78",
"world 79",
"world 80",
"world 81",
"world 82",
"world 83",
"world 84",
"world 85",
"world 86",
"world 87",
"world 88",
"world 89",
"world 90",
"world 91",
"world 92",
"world 93",
"world 94",
"world 95",
"[0]",
"[1]",
"[2]",
"[3]",
"[4]",
"[5]",
"[6]",
"[7]",
"[8]",
"[9]",
"[.]",
"[/]",
"[*]",
"[-]",
"[+]",
"enter",
"equals",
"up",
"down",
"right",
"left",
"insert",
"home",
"end",
"page up",
"page down",
"f1",
"f2",
"f3",
"f4",
"f5",
"f6",
"f7",
"f8",
"f9",
"f10",
"f11",
"f12",
"f13",
"f14",
"f15",
"",
"",
"",
"numlock",
"caps lock",
"scroll lock",
"right shift",
"left shift",
"right ctrl",
"left ctrl",
"right alt",
"left alt",
"right cmd",
"left cmd",
"left super",
"right super",
"alt gr",
"compose",
"help",
"print screen",
"sys req",
"break",
"menu",
"power",
"euro",
"undo",
"mouse 0",
"mouse 1",
"mouse 2",
"mouse 3",
"mouse 4",
"mouse 5",
"mouse 6",
"joystick button 0",
"joystick button 1",
"joystick button 2",
"joystick button 3",
"joystick button 4",
"joystick button 5",
"joystick button 6",
"joystick button 7",
"joystick button 8",
"joystick button 9",
"joystick button 10",
"joystick button 11",
"joystick button 12",
"joystick button 13",
"joystick button 14",
"joystick button 15",
"joystick button 16",
"joystick button 17",
"joystick button 18",
"joystick button 19",
"joystick 1 button 0",
"joystick 1 button 1",
"joystick 1 button 2",
"joystick 1 button 3",
"joystick 1 button 4",
"joystick 1 button 5",
"joystick 1 button 6",
"joystick 1 button 7",
"joystick 1 button 8",
"joystick 1 button 9",
"joystick 1 button 10",
"joystick 1 button 11",
"joystick 1 button 12",
"joystick 1 button 13",
"joystick 1 button 14",
"joystick 1 button 15",
"joystick 1 button 16",
"joystick 1 button 17",
"joystick 1 button 18",
"joystick 1 button 19",
"joystick 2 button 0",
"joystick 2 button 1",
"joystick 2 button 2",
"joystick 2 button 3",
"joystick 2 button 4",
"joystick 2 button 5",
"joystick 2 button 6",
"joystick 2 button 7",
"joystick 2 button 8",
"joystick 2 button 9",
"joystick 2 button 10",
"joystick 2 button 11",
"joystick 2 button 12",
"joystick 2 button 13",
"joystick 2 button 14",
"joystick 2 button 15",
"joystick 2 button 16",
"joystick 2 button 17",
"joystick 2 button 18",
"joystick 2 button 19",
"joystick 3 button 0",
"joystick 3 button 1",
"joystick 3 button 2",
"joystick 3 button 3",
"joystick 3 button 4",
"joystick 3 button 5",
"joystick 3 button 6",
"joystick 3 button 7",
"joystick 3 button 8",
"joystick 3 button 9",
"joystick 3 button 10",
"joystick 3 button 11",
"joystick 3 button 12",
"joystick 3 button 13",
"joystick 3 button 14",
"joystick 3 button 15",
"joystick 3 button 16",
"joystick 3 button 17",
"joystick 3 button 18",
"joystick 3 button 19",
"joystick 4 button 0",
"joystick 4 button 1",
"joystick 4 button 2",
"joystick 4 button 3",
"joystick 4 button 4",
"joystick 4 button 5",
"joystick 4 button 6",
"joystick 4 button 7",
"joystick 4 button 8",
"joystick 4 button 9",
"joystick 4 button 10",
"joystick 4 button 11",
"joystick 4 button 12",
"joystick 4 button 13",
"joystick 4 button 14",
"joystick 4 button 15",
"joystick 4 button 16",
"joystick 4 button 17",
"joystick 4 button 18",
"joystick 4 button 19",
"joystick 5 button 0",
"joystick 5 button 1",
"joystick 5 button 2",
"joystick 5 button 3",
"joystick 5 button 4",
"joystick 5 button 5",
"joystick 5 button 6",
"joystick 5 button 7",
"joystick 5 button 8",
"joystick 5 button 9",
"joystick 5 button 10",
"joystick 5 button 11",
"joystick 5 button 12",
"joystick 5 button 13",
"joystick 5 button 14",
"joystick 5 button 15",
"joystick 5 button 16",
"joystick 5 button 17",
"joystick 5 button 18",
"joystick 5 button 19",
"joystick 6 button 0",
"joystick 6 button 1",
"joystick 6 button 2",
"joystick 6 button 3",
"joystick 6 button 4",
"joystick 6 button 5",
"joystick 6 button 6",
"joystick 6 button 7",
"joystick 6 button 8",
"joystick 6 button 9",
"joystick 6 button 10",
"joystick 6 button 11",
"joystick 6 button 12",
"joystick 6 button 13",
"joystick 6 button 14",
"joystick 6 button 15",
"joystick 6 button 16",
"joystick 6 button 17",
"joystick 6 button 18",
"joystick 6 button 19",
"joystick 7 button 0",
"joystick 7 button 1",
"joystick 7 button 2",
"joystick 7 button 3",
"joystick 7 button 4",
"joystick 7 button 5",
"joystick 7 button 6",
"joystick 7 button 7",
"joystick 7 button 8",
"joystick 7 button 9",
"joystick 7 button 10",
"joystick 7 button 11",
"joystick 7 button 12",
"joystick 7 button 13",
"joystick 7 button 14",
"joystick 7 button 15",
"joystick 7 button 16",
"joystick 7 button 17",
"joystick 7 button 18",
"joystick 7 button 19",
"joystick 8 button 0",
"joystick 8 button 1",
"joystick 8 button 2",
"joystick 8 button 3",
"joystick 8 button 4",
"joystick 8 button 5",
"joystick 8 button 6",
"joystick 8 button 7",
"joystick 8 button 8",
"joystick 8 button 9",
"joystick 8 button 10",
"joystick 8 button 11",
"joystick 8 button 12",
"joystick 8 button 13",
"joystick 8 button 14",
"joystick 8 button 15",
"joystick 8 button 16",
"joystick 8 button 17",
"joystick 8 button 18",
"joystick 8 button 19",
"joystick 9 button 0",
"joystick 9 button 1",
"joystick 9 button 2",
"joystick 9 button 3",
"joystick 9 button 4",
"joystick 9 button 5",
"joystick 9 button 6",
"joystick 9 button 7",
"joystick 9 button 8",
"joystick 9 button 9",
"joystick 9 button 10",
"joystick 9 button 11",
"joystick 9 button 12",
"joystick 9 button 13",
"joystick 9 button 14",
"joystick 9 button 15",
"joystick 9 button 16",
"joystick 9 button 17",
"joystick 9 button 18",
"joystick 9 button 19",
"joystick 10 button 0",
"joystick 10 button 1",
"joystick 10 button 2",
"joystick 10 button 3",
"joystick 10 button 4",
"joystick 10 button 5",
"joystick 10 button 6",
"joystick 10 button 7",
"joystick 10 button 8",
"joystick 10 button 9",
"joystick 10 button 10",
"joystick 10 button 11",
"joystick 10 button 12",
"joystick 10 button 13",
"joystick 10 button 14",
"joystick 10 button 15",
"joystick 10 button 16",
"joystick 10 button 17",
"joystick 10 button 18",
"joystick 10 button 19",
"joystick 11 button 0",
"joystick 11 button 1",
"joystick 11 button 2",
"joystick 11 button 3",
"joystick 11 button 4",
"joystick 11 button 5",
"joystick 11 button 6",
"joystick 11 button 7",
"joystick 11 button 8",
"joystick 11 button 9",
"joystick 11 button 10",
"joystick 11 button 11",
"joystick 11 button 12",
"joystick 11 button 13",
"joystick 11 button 14",
"joystick 11 button 15",
"joystick 11 button 16",
"joystick 11 button 17",
"joystick 11 button 18",
"joystick 11 button 19"
};
}