# Actionscript 3 key events

**URL:** <https://forum.kirupa.com/t/actionscript-3-key-events/201711>\
**Category:** Uncategorized\
**Created:** [September 24, 2006, 11:06am UTC](https://forum.kirupa.com/t/actionscript-3-key-events/201711 "2006-09-24T11:06:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![slideth3](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@slideth3](https://forum.kirupa.com/u/slideth3)\
**Post date:** [September 24, 2006, 11:06am UTC](https://forum.kirupa.com/t/actionscript-3-key-events/201711/1 "2006-09-24T11:06:19Z")

</div>

Hi, I’ve just started with actionscript 3 in flash 9 alpha. Its great and a lot of it seems to be an improvement… except key events!

Now normally I would do something like

```auto

if(Key.isDown(39)) _x++;

```

to move something to the right, but in as3 The only way i’ve discovered to do it so far is to go

```auto

addEventListener(KeyboardEvent.KEY_DOWN, keyDown)

```

then add a function which acts on keydown, using KeyCode or CharCode to tell which key has been pressed.

The problem with this is that it acts more like onKeyPress rather than  
onEnterFrame{ if(keyisDown) } in actionscript 2, ie its not a constantt thing, so the movement is jumpy. Is there any efficient way to do what i would have done in actionscript 2 in the past?

Thanks for any help!!

Sam 🙂
