Getting the key i pressed back

i am trying to make a function that will tell me if i pressed a key, the key codes are stored in an array i need to check if a key pressed matches any in the array, it matches the first key code in the array but not the second or last one. btw the key codes in the array are the up and the w key


var controls:Object = new Object();
controls.upKey = Array(38, 87);
controls.up = function(keyPressed):Boolean  {
    for (i=0; i<controls.upKey.length; i++) {
        if (controls.upKey* == keyPressed) {
            return true;
        } else {
            return false;
        }
    }
};