Hi,

I meant to say that inputkey is a var parameter. I was writing it off the cuff without Delphi :-) !!

In the game that I am writing I am only interested in a single VK_NUMPAD 1..9 keys being pressed. Multiple key presses don't worry me, but technically they are not valid.

[pascal]
procedure GetInput(var inputkey : integer);
var
KeyState: TKeyboardState;
begin
inputkey := 0;
if (GetKeyboardState(KeyState) <> 0) then
begin
// I only want to capture keys VK_NUMPAD1..VK_NUMPAD9
// and return inputkey = 1..9 respectively

if ((KeyState[VK_NUMPAD1] and $80) <> 0) then
inputkey := 1;
if ((KeyState[VK_NUMPAD2] and $80) <> 0) then
inputkey := 2;
if ((KeyState[VK_NUMPAD3] and $80) <> 0) then
inputkey := 3;
if ((KeyState[VK_NUMPAD4] and $80) <> 0) then
inputkey := 4;
if ((KeyState[VK_NUMPAD5] and $80) <> 0) then
inputkey := 5;
if ((KeyState[VK_NUMPAD6] and $80) <> 0) then
inputkey := 6;
if ((KeyState[VK_NUMPAD7] and $80) <> 0) then
inputkey := 7;
if ((KeyState[VK_NUMPAD8] and $80) <> 0) then
inputkey := 8;
if ((KeyState[VK_NUMPAD9] and $80) <> 0) then
inputkey := 9;
end
else
; // don't care
{GetKeyboardState failed, handle it if necessary}
end;
[/pascal]

I guess that I could rewritten the if statements to use elses:
[pascal]
...
if ((KeyState[VK_NUMPAD1] and $80) <> 0) then
inputkey := 1
else if ((KeyState[VK_NUMPAD2] and $80) <> 0) then
inputkey := 2
else if ...
[/pascal]