You can do this also using onKeyDown onKeyUp events of form.

[pascal]First define public variable:
keys: array[0..255] of boolean;

onKeyDown:
if key<256 then Keys[key]:=true;

onKeyUp:
if key<256 then Keys[key]:=false;

Now in your main application loop you can use it:
if keys[VK_UP] then MoveForward;
if keys[VK_DOWN] then MoveBack;
if keys[VK_LEFT] then StrafeLeft;
if keys[VK_RIGHT] then StrafeRight;
if keys[ord('Z')] then Shoot;[/pascal]