# Help with javascript-key codes

**URL:** <https://forum.kirupa.com/t/help-with-javascript-key-codes/233866>\
**Category:** Uncategorized\
**Created:** [July 27, 2007, 4:10pm UTC](https://forum.kirupa.com/t/help-with-javascript-key-codes/233866 "2007-07-27T16:10:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mofongo9](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@mofongo9](https://forum.kirupa.com/u/mofongo9)\
**Post date:** [July 27, 2007, 4:10pm UTC](https://forum.kirupa.com/t/help-with-javascript-key-codes/233866/1 "2007-07-27T16:10:41Z")

</div>

im learning javascript after knowing actionscript, and im trying to make a little thing where a guy moves around when you use w,a,s,d. the keys are registering but for some reason the guy refuses to move. heres the code, can you tell me whats wrong with it? btw to view the whole thing ull need an image man-up.jpg.

```auto
 
<html>
<head>
<title>Walking Around in Javascript</title>
<script type="text/javascript">
var manX=200;
var manY=150;
var walkSpeed=10;
function updatePosition() {
 document.getElementById('man').style.left=manX+'px'
 document.getElementById('man').style.top=manY+'px'
}
</script>
</head>
<body onkeyup="if(event.keyCode=='W'.charCodeAt(0)) {
 manY-=walkSpeed
 updatePosition()
}
if(event.keyCode=='D'.charCodeAt(0)) {
 manX+=walkSpeed
 updatePosition()
}
if(event.keyCode=='S'.charCodeAt(0)) {
 manY+=walkSpeed
 updatePosition()
}
if(event.keyCode=='A'.charCodeAt(0)) {
 manX-=walkSpeed
 updatePosition()
}">
<input type="button" id="man" style="left:150px; top:200px" value="test">
</body>
</html>

```
