Witam
mam taki problem że chciałbym w moim projekcie mieć obsługę klawiatury i jednocześnie kilka buttonów, niestety naciskanie klawiszy nic nie daje jeśli na tej samej formie znajduje się jakikolwiek button - jak to oszukać? ( dwie formy nie wchodzą w grę, chyba że ta druga by nasłuchiwała wszyskie zdarzenia klawiatury i nie trzeba jej było mieć na wierzchu )
mój kod:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ToolWin, ComCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Button1: TButton;
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_LEFT then Shape1.left := Shape1.left - 10; if Key = VK_RIGHT then Shape1.left := Shape1.left + 10; if Key = VK_UP then Shape1.top := Shape1.top - 10; if Key = VK_DOWN then Shape1.top := Shape1.top + 10;
end;
END.