# Getting key presses to fire only once

**URL:** <https://forum.kirupa.com/t/getting-key-presses-to-fire-only-once/239257>\
**Category:** Uncategorized\
**Created:** [September 19, 2007, 11:11pm UTC](https://forum.kirupa.com/t/getting-key-presses-to-fire-only-once/239257 "2007-09-19T23:11:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hausnfranz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hausnfranz/32/2427_2.png) [@Hausnfranz](https://forum.kirupa.com/u/Hausnfranz)\
**Post date:** [September 19, 2007, 11:11pm UTC](https://forum.kirupa.com/t/getting-key-presses-to-fire-only-once/239257/1 "2007-09-19T23:11:43Z")

</div>

Hi all,

I set up some code to record key presses and specific chords. My problem is that I only want the keys to fire once when pressed. This is especially a problem when I require the user to hold CTRL + LEFT for an action.

The user experience is that I want users to hold down CTRL to enter a mode and then press the LEFT key as many times as needed. Currently, the CTRL trace and LEFT trace fire continuously. Is there a way to do a onKeyRelease?

```auto

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    if (Key.isDown(Key.CONTROL)) {
        trace("control is down");
        if ((Key.isDown(Key.LEFT))) {
            trace("delete a key");
                        }
    } 
    if (Key.isDown(Key.LEFT)) {
        trace("left is down");
    }
    if (Key.isDown(Key.UP)) {
        trace("up is down");
    }
    if (Key.isDown(Key.RIGHT)) {
        trace("right is down");
    }
    if (Key.isDown(Key.DOWN)) {
        trace("down is down");
    }
};
keyListener.onKeyUp = function() {
}
Key.addListener(keyListener);

```

thanks,

nick
