Creating a Delphi application shortcut without a corresponding menu item

I want a keyboard shortcut (e.g. Ctrl + Alt + D) in my application to call a function, but I don't want the shortcut to appear in any menu. Is it possible to have a shortcut in your application that is otherwise invisible?

+6
delphi menu shortcut taction tmenuitem
source share
2 answers

you can use the OnShortCut event for this task

check this code

 procedure TForm1.ApplicationEvents1ShortCut(var Msg: TWMKey; var Handled: Boolean); begin if (Msg.CharCode = Ord('D')) and (HiWord(Msg.KeyData) and KF_ALTDOWN <> 0) and (GetKeyState(VK_CONTROL) < 0) then begin ShowMessage('Ctrl+Alt+D Pressed') ; Handled := true; end; end; 
+11
source share

Yes it is possible. You must add an object of the TAction class to your form. You can specify a keyboard shortcut for Taction, and then put your code in the OnExecute event of TAction.

Note that you cannot add a Taction directly to your form, you must put a TactionList in your form, and then add a Taction to your TActionList.

+8
source share

All Articles