Box2D and Keyboard input [FIXED]

I'm trying to figure out how Box2D works and am currently phailing miserably. I'm planning on using Box2D with SFML, using Box2D mainly for collision detection. Unfortunately I'm having trouble figuring out how to work Box2D properly. I (think) I've gotten the unit scaling to work but now my problem is keyboard input. My game is a simple 2D space shooter where the player moves with either the arrow keys or WASD. How do I change a b2Body's position manually? Or do I have to use forces, impulses, etc?

I saw a similar post on the AS3 subforum and I tried to use Impulses, which worked fairly well, but I want the Body to stop moving when I release the arrow key. How would I do that? I tried a setLinearVelocity but all that did was prevent the Body from moving at all.
You've got the right approach I think. Perhaps you're calling SetLinearVelocity at the wrong time?
I've gotten it to somewhat work now, except only the horizontal buttons/forces work. For some reason I cannot get the up and down keys to work; I think it has something to do with how I set up my forces. Here's what I have:
Code:
   xForce=b2Vec2(30.f,0);
   yForce=b2Vec2(0,30.f);
...

   const b2Vec2& vel=physBody->GetLinearVelocity();
   if(dir&UP&&!(dir&DOWN))
   {
      physBody->SetLinearVelocity(b2Vec2(vel.x,0));
      physBody->ApplyImpulse(-yForce,physBody->GetLocalCenter());
   }
   else if(dir&DOWN&&!(dir&UP))
   {
      physBody->SetLinearVelocity(b2Vec2(vel.x,0));
      physBody->ApplyImpulse(yForce,physBody->GetLocalCenter());
   }
   else
      physBody->SetLinearVelocity(b2Vec2(vel.x,0));
   if(dir&LEFT&&!(dir&RIGHT))
   {
      physBody->SetLinearVelocity(b2Vec2(0,vel.y));
      physBody->ApplyImpulse(-xForce,physBody->GetLocalCenter());
   }
   else if(dir&RIGHT&&!(dir&LEFT))
   {
      physBody->SetLinearVelocity(b2Vec2(0,vel.y));
      physBody->ApplyImpulse(xForce,physBody->GetLocalCenter());
   }
   else
      physBody->SetLinearVelocity(b2Vec2(0,vel.y));

Again the left and right seem to work fine though the up and down do work at all (it reaches the if statement just doesnt cause it to move).
it seems setLinearVelocity negates my setting of Impulse.

How do I make it so if I press a key the body moves and if I release a key the body doesn't move? Do I just do an Impulse in the opposite direction (negative Impulse)?

EDIT: fixed it, just had a temp b2Vec2 for the velocity and used SetLinearVelocity at the end. totally fixed it ^_^.

Original thread: https://box2d.org/forum/viewtopic.php?t=2892