it seems overly complex to me. You really didn't need to use all those variables for defining keys and stuff. If you want, here's mine, it's for A6, but I'm pretty sure it would be easy to convert if you have A7:

Note: these functions already include support for all keys on an american keyboard (that 3DGS will allow) and the mouse buttons.

Code:
string keystr[50];
string tmpkey[50];
string oldkey[50];

//these are string definitions for your movement keys, these are what you would 
//use in the menu as the strings for the keys to be shown
string up_str = "Up"; 
string left_str = "Left";
string right_str = "Right";
string down_str = "Down";
///these are the variables you will use with the press_key(num) function
var_info up = 72;
var_info left = 75;
var_info right = 77;
var_info down = 80;

///if you want to add support for more keys that aren't working, add them here
function set_keyname(keystr)
{
	if (key_lastpressed <= 255) //if the scancode is lessthan or equal to 255
	{
		str_for_key (keystr,key_lastpressed);
		if (key_lastpressed == 14)
		{
			str_cpy (keystr, "backspace");
		}
		if (key_lastpressed == 42)
		{
			str_cpy (keystr, "left shift");
		}
		if (key_lastpressed == 54)
		{
			str_cpy (keystr, "right shift");
		}
		if (key_lastpressed == 82)
		{
			str_cpy (keystr, "insert");
		}
		if (key_lastpressed == 83)
		{
			str_cpy (keystr, "delete");
		}
		if (key_lastpressed == 73)
		{
			str_cpy (keystr, "page up");
		}
		if (key_lastpressed == 81)
		{
			str_cpy (keystr, "page down");
		}
		if (key_lastpressed == 72)
		{
			str_cpy (keystr, "up arrow");
		}
		if (key_lastpressed == 80)
		{
			str_cpy (keystr, "down arrow");
		}
		if (key_lastpressed == 75)
		{
			str_cpy (keystr, "left arrow");
		}
		if (key_lastpressed == 77)
		{
			str_cpy (keystr, "right arrow");
		}
		if (key_lastpressed == 12)
		{
			str_cpy (keystr, "minus");
		}
		if (key_lastpressed == 43)
		{
			str_cpy (keystr, "backslash");
		}
		if (key_lastpressed == 39)
		{
			str_cpy (keystr, "semicolon");
		}
		if (key_lastpressed == 40)
		{
			str_cpy (keystr, "apostrophie");
		}
		if (key_lastpressed == 51)
		{
			str_cpy (keystr, "comma");
		}
		if (key_lastpressed == 52)
		{
			str_cpy (keystr, "period");
		}
		if (key_lastpressed == 70)
		{
			str_cpy (keystr, "scroll lock");
		}
	}
	else //if the scancode is more than 255, joystick buttons would be added here
	{
		if (key_lastpressed == 280)
		{
			str_cpy (keystr, "mouse left");
		}
	}
}

function reset_key(keystr, tmpkey)
{
	str_cpy(oldkey, tmpkey);
	recheck:
	while (key_any) { wait(1); }
	str_cpy (tmpkey, "Press A Key");
	mouse_mode = 0;
	//freeze_mode = 1;
	while (key_any == null) { wait(1); }
	if (!key_pressed(55) && !key_pressed(key_for_str("esc")) && !key_pressed(key_for_str("grave")))
	{
		str_for_num(keystr, key_lastpressed);
		set_keyname (tmpkey);
		while (key_any) { wait(1); }
		mouse_mode = 1;
		return;
		//freeze_mode = 0;
	}
	if (key_pressed(key_for_str("esc")))
	{
		str_cpy(tmpkey, oldkey); return;
	}
	str_cpy (tmpkey, "Invalid Key");
	sleep(1);
	goto(recheck);
}

function press_key(num)
{
	return(key_pressed(num));
}



now, for the way you use it. First of all, to change the key that is mapped, do this:

reset_key(key_variable, key_string);

so, for the up key that would be:

reset_key(up, up_str);

what this will do is wait for you to press a key to map it to, if you press esc it quits the function and resets the key to the old one. ~ will just return a "incorrect key" because most people use this for a console, if you don't like this just erase the && !key_pressed(key_for_str("grave")) from the reset_key function.

now, to use the keys in the game, just do this:

if (press_key(key_variable)) { ///blahblahblah }

for up that will be:

if (press_key(up)) { ///blahblahblah }

you could replace your:

if(keycode == k_moveForward){CamEnt.camforce_x += 1;}

commands with:

if (press_key(up)) {CamEnt.camforce_x += 1;}

like I said, you can use any key that 3DGS allows, all you have to do to enable them for the string is add the keys you want to allow in the set_keyname(keystr) function, you don't use this function yourself, so all you need to do is add keys here, i'll show how to add joystick 1 button 1:

joystick 1 button 1 scan code is 256, so under this line:

else //if the scancode is more than 255, joystick buttons would be added here
{
if (key_lastpressed == 280)
{
str_cpy (keystr, "mouse left");
}
if (key_lastpressed == 256)
{
str_cpy (keystr, "joy1 button1"); // you could put whatever name you want here
}
}

I hope this helps laugh


- aka Manslayer101