Changing controls in game, after application has launched

Hi, I want to know if it is possible to change control inputs in-game (after the application has launched). For example, I could have a “Change Controls” menu in the main menu, where the user can click on a box, for example “Move forward”, press what button they want to move forward, and have that button be saved as the move forward key.

One solutions is to put your keycode checks into variables. Something like (in C#):

KeyCode kcForward = KeyCode.UpArrow;
if (Input.GetKeyDown (kcForward)) { // Do the forward stuff }

Later you can reassign the value.

kcFordward = KeyCode.W;

So now the ‘W’ key will move forward. Of course you’ll have to write the interface that allows the user to change the keys mappings for your game.

I tried using the solution provided and I still can’t get my player to move. Here’s what I put

enter code here
using UnityEngine;
using System.Collections;

public class Change_Controls : MonoBehaviour {

	public string moveForward = "x";
	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
		    KeyCode kcForward = KeyCode.X;
    if (Input.GetKeyDown (kcForward)) { // Do the forward stuff }
			kcForward = KeyCode.X;