Not sure I completely understand what you're trying to do but I suppose you could do something like this:
PHP Code:
//#CLIENTSIDE
function GraalControl.onKeyDown(kcode, kstring, scode)
{
temp.keyList = {{38, 0}, {37, 1}, {40, 2}, {39, 3}}; //Up, Left, Down, Right
for (i = 0; i < keyList.size(); i++)
{
if (keyList[i][0] == kcode)
{
player.chat = keyname(keyList[i][1]);
}
}
}