# Assigning keypress... please help!

**URL:** <https://forum.kirupa.com/t/assigning-keypress-please-help/239891>\
**Category:** Uncategorized\
**Created:** [September 26, 2007, 9:45pm UTC](https://forum.kirupa.com/t/assigning-keypress-please-help/239891 "2007-09-26T21:45:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fandalis](https://avatars.discourse-cdn.com/v4/letter/f/6f9a4e/32.png) [@fandalis](https://forum.kirupa.com/u/fandalis)\
**Post date:** [September 26, 2007, 9:45pm UTC](https://forum.kirupa.com/t/assigning-keypress-please-help/239891/1 "2007-09-26T21:45:21Z")

</div>

Hi there,  
I just want to ask some advise on how to change the directional arrows to keyboard letters on keypress. the browser scrolls when i press arrow up and down arrows and it’s quite annoying. i just want to change the keypress of up arrow to w, then left arrow to a, right arrow to d and down arrow to s. just one of any will do then i’ll do the rest.

here’s the code:

function detectKeys() {  
var ob = \_root.char;  
var keyPressed = false;  
if (Key.isDown(Key.RIGHT)) {  
keyPressed = \_root.moveChar(ob, 1, 0);  
} else if (Key.isDown(Key.LEFT)) {  
keyPressed = \_root.moveChar(ob, -1, 0);  
} else if (Key.isDown(Key.UP)) {  
keyPressed = \_root.moveChar(ob, 0, -1);  
} else if (Key.isDown(Key.DOWN)) {  
keyPressed = \_root.moveChar(ob, 0, 1);  
}  
// walk animation  
if (!keyPressed) {  
ob.clip.char.gotoAndStop(1);  
} else {  
ob.clip.char.play();  
}  
}

thanks a lot!!!
