Hi,

Is there a better way for me to do this:

PEW

[pascal]
procedure GetInput();
var
KeyState: TKeyboardState;
inputkey : integer;
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]