var Keys: string; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key >= $41) and (Key <= $5A) then begin Keys := Keys + chr(Key); if Keys = 'TEST' then begin Keys := ''; ShowMessage('Test'); end; end; end; |
: | 例如实现:在form上依次按下t e s t,四个键,然后form响应事件 |
var Keys: string; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key >= $41) and (Key <= $5A) then begin Keys := Keys + chr(Key); if Keys = 'TEST' then begin Keys := ''; ShowMessage('Test'); end; end; end; |