Peter Martin's Delphi Tips

Assign a Special Short-cut Key to a Menu Item

Delphi's object inspector only allows a limited set of short-cut key assignments to menu items. These examples show how to assign Alt-X and Ctrl-F4 to the menu item Exit1:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Exit1.ShortCut:= ShortCut(word('X'), [ssAlt]);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Exit1.ShortCut:= ShortCut(VK_F4, [ssCtrl]);
end;