<p>I've got a canvas that's 800x600 inside a window that's 300x300. When I press a certain key, I want it the canvas to move in that direction.<br>
I've done this inside the window's code behind:</p>

<pre>
protected override void OnKeyDown(KeyEventArgs e)
{
    base.OnKeyDown(e);
    Key keyPressed = e.Key;

    if (keyPressed == Key.W)
    {
        gcY += 5;
    }
    if (keyPressed == Key.S)
    {
        gcY -= 5;
    }
    if (keyPressed == Key.A)
    {
        gcX += 5;
    }
    if (keyPressed == Key.D)
    {
        gcX -= 5;
    }

    gameCanvas.RenderTransform = new TranslateTransform(gcX, gcY);
}
</pre>

<p>Well, it works, but the movement is jerky. And if I hold on to a key, <kbd>W</kbd> for instance, then it pauses for a split second, before moving.<br>
Is there anyway to make the movement smoother and to get rid of the pause when you hold down a key?<br>
Thanks.</p>

Yes, you could incorporate the time into your calculation. Currently you add/substract 5 whenever the event fires, and that's not really predictable.
To smoothe the movement make sure you don't fire more often than X times per second by using a DateTime.
like:
```
```
private static DateTime nextUpdate

if (nextUpdate <= DateTime.Now)
{
//Move
nextUpdate = DateTime.Now.AddMilliseconds(100);
}
```
```
I don't have VS right now, so I'm not perfectly sure for the syntax, but you get the idea.