# Getting the key i pressed back

**URL:** <https://forum.kirupa.com/t/getting-the-key-i-pressed-back/217061>\
**Category:** Uncategorized\
**Created:** [February 22, 2007, 5:38pm UTC](https://forum.kirupa.com/t/getting-the-key-i-pressed-back/217061 "2007-02-22T17:38:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajcates](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ajcates/32/2435_2.png) [@ajcates](https://forum.kirupa.com/u/ajcates)\
**Post date:** [February 22, 2007, 5:38pm UTC](https://forum.kirupa.com/t/getting-the-key-i-pressed-back/217061/1 "2007-02-22T17:38:28Z")

</div>

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

```auto

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;
        }
    }
};

```
