Page 1 of 1

using the arrow keys

PostPosted: March 9th, 2009, 11:03 am
by stowaway
Hello,
Im very new to delphi programming..
I had moderate experience with turbo pascal in my high school days, but nothing extreme.

Im trying to run my RC car through my computer.. any how i want to use the Arrow keys. Ive got to the point where I can detect keydown VK_UP (VK_DOWN ect) but i have to hold the ALT key for it to work...
Also I want to be able to detect if 2 keys are pressed (ie UP AND LEFT) heres what ive got so far:

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case key of
VK_LEFT: label1.Caption := 'This is Left Key';
VK_UP : label1.Caption := 'This is the up key';
end;
end;

Re: using the arrow keys

PostPosted: March 9th, 2009, 11:45 am
by Kambiz
You may want to consider using this function inside a timer.

Code: Select all
function IsKeyDown(VirtualKey: Integer): Boolean;
begin
  Result := WordBool(GetKeyState(VirtualKey) and $8000);
end;