Edit keys in game

Hello iam making a options menu and i would like the player to change the keys if he want too ex: change jump to another key, i have this right now:

public KeyCode Jump = KeyCode.Space;


GUILayout.BeginHorizontal();
        GUILayout.Space(15);
        GUILayout.Label("Jump:", Text);
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("" + Jump, Button, GUILayout.Height(40), GUILayout.Width(260)))
        {
            if(Input.GetKeyDown(KeyCode.A))
                Jump = KeyCode.A;
            if (Input.GetKeyDown(KeyCode.AltGr))
                Jump = KeyCode.AltGr;
            if (Input.GetKeyDown(KeyCode.B))
                Jump = KeyCode.B;
            if (Input.GetKeyDown(KeyCode.Backspace))
                Jump = KeyCode.Backspace;
            if (Input.GetKeyDown(KeyCode.C))
                Jump = KeyCode.C;

        }
        GUILayout.Space(15);
        GUILayout.EndHorizontal();

is it possible to make it easier like instead of this

if(Input.GetKeyDown(KeyCode.A))
                        Jump = KeyCode.A;
                    if (Input.GetKeyDown(KeyCode.AltGr))
                        Jump = KeyCode.AltGr;
                    if (Input.GetKeyDown(KeyCode.B))
                        Jump = KeyCode.B;
                    if (Input.GetKeyDown(KeyCode.Backspace))
                        Jump = KeyCode.Backspace;
                    if (Input.GetKeyDown(KeyCode.C))
                        Jump = KeyCode.C;

my english is not so good and i hope you understand
thanks

You can use OnGUI() and do something like this:

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {

	KeyCode[] codes = new KeyCode[] {KeyCode.A, KeyCode.AltGr, KeyCode.B, KeyCode.C};
	public KeyCode jump = KeyCode.Space;

	void OnGUI() {
		Event e = Event.current;
		if (e.type == EventType.keyDown && System.Array.Exists<KeyCode>(codes, element => element == e.keyCode)) {
			jump = e.keyCode;
		}
	}
}

all I can say is there is a really simple answer.

have a script set aside call KEYID and inside it have static strings of lowercase letters or the key assignment code. then when your needing to do a action with the keybind what you do is
Input.GetKey(KEYID.*the name of the variable here*)

there u go :smiley: