Or....
Just use the raw windows messages:
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
procedure WMKeyDown(var Message : TWMKeyDown); message WM_KEYDOWN;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.WMKeyDown(var Message: TWMKeyDown);
begin
if message.CharCode = VK_LEFT then
form1.Left := form1.Left- 2;
if message.CharCode = VK_RIGHT then
form1.Left := form1.Left+ 2;
if message.CharCode = VK_UP then
form1.top := form1.top- 2;
if message.CharCode = VK_DOWN then
form1.top := form1.top+ 2;
end;
end.
Works quite well. With a delay and repeats.
Bookmarks