public void keyPressed(KeyEvent e) 
    {

        int key = e.getKeyCode();

        if (key == KeyEvent.VK_SPACE)
        {
            fire();
        }

        if (key == KeyEvent.VK_A) 
        {
            dx = -1;
        }

        if (key == KeyEvent.VK_D)
        {
            dx = 1;
        }

        if (key == KeyEvent.VK_W) 
        {
            dy = -1;
        }

        if (key == KeyEvent.VK_S) 
        {
            dy = 1;
        }
    }