# onKeypress , on event handler

**URL:** https://forum.kirupa.com/t/onkeypress-on-event-handler/296576
**Category:** flash
**Created:** [September 16, 2009, 9:21pm UTC](https://forum.kirupa.com/t/onkeypress-on-event-handler/296576 "2009-09-16T21:21:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mihaispr](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mihaispr](https://forum.kirupa.com/u/mihaispr)
#### Post date: [September 16, 2009, 9:21pm UTC](https://forum.kirupa.com/t/onkeypress-on-event-handler/296576/1 "2009-09-16T21:21:50Z")

</div>

I have a triangle placed on scene that I can control when I press up arrow,down ,left and right arrow.

Here is the code:

```auto

onClipEvent(enterFrame)
{
}
on (keyPress "<Left>") {
    this._x -= 10;
}
on (keyPress "<Right>") {
    this._x += 10;
}

on (keyPress "<Down>") {
    this._y += 12;
}
on (keyPress "<Up>") {
    this._y -= 12;
}

```

My question is if I can use on(keypress) on touching a certain key to display me in output panel that I press ESC for example to display me ESCAPE key was pressed.

So when I press ESC I want to display a message in output. How can I do that?

I try this (I want to perform several displays):

```auto

on(keyPress "<Escape>")
{
trace("ESCAPE key was pressed");
}

on (keyPress "<Home>")
{trace("HOME key was pressed");
}

on(keyPress "<Insert>")
{trace("INSERT key was pressed");
}

on(keyPress "<Space>")
{trace("SPACE key was pressed");
}

on(keyPress "<Delete>")
{trace("DELETE key was pressed");
}

```

Please help! If it’s possible to get Ascii code from ESC key display it and then display that message in trace all these in output panel.
