'Moving a character within an array on a html page using php, jquery and onkeydown events

I'm learning some web programming programming right now and I'm a little stuck.

I'm trying to move a character around an array (like a simple rogue-like game) using the WASD keys but I can't seem to figure it out.

So I was wondering if someone could explain to me what I'm doing wrong exactly?

heres the code:

<html>
<body style="font-family: Courier" onkeydown="move(event)">
<p id="game" >
<?php

// php functions regarding movement

    $map = array(
    "XXXXXXXXXX",
    "X........X",
    "X...XX...X",
    "X...XX...X",
    "X........X",
    "XXXX..XXXX",
    "X........X",
    "X..X..X..X",
    "X........X",
    "XXXXXXXXXX",

    );

    $player = new Player(2,2,"T");
    initMap($map);
    makePlayer($player);
    displayMap($map);
?>
</p>
<script  type="text/javascript" src="jquery.js">

function move(ev){
    var key = (ev) ? ev.which : event.keyCode;
    var c = String.fromCharCode(key);
    $("#game").html('function move is working') 

    switch(c){
    case "w":
        <?php 
            moveUp();
        ?>
        $("#game").empty();
    
        break;

    // keys ASD all share same code

    default:
        break;
    
}
}
</script>
</body>
</html>


/* output, no changes when key is pressed:

XXXXXXXXXX
X........X
X.T.XX...X
X...XX...X
X........X
XXXX..XXXX
X........X
X..X..X..X
X........X
XXXXXXXXXX
*/

Pressing any of the keys should clear the html from the #game div, but it does not. Any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source