I use the TApplicationEvents.OnShortCut
event in Delphi 11 Alexandria with a Delphi VCL Application in Windows 10, for example:
procedure TformMain.ApplicationEvents1ShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
CodeSite.Send('TformMain.ApplicationEvents1ShortCut: Msg.CharCode', Msg.CharCode);
end;
Unfortunately, this event is even triggered when no modifier key is pressed, e.g. the "V" key or the "B" key alone. How can I exit this event handler when no modifier key is pressed, for example:
procedure TformMain.ApplicationEvents1ShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
if NoModifierKeyPressed then EXIT;
...
end;
Taking into account the kind comments of @RemyLebeau and @Andreas Rejbrand:
This works for me:
function NoModifierKeyPressed: Boolean;
var
keys: TKeyboardState;
begin
GetKeyboardState(keys);
Result := (keys[VK_SHIFT] and $80 = 0) and (keys[VK_CONTROL] and $80 = 0) and (keys[VK_MENU] and $80 = 0);
end;