[fpc-pascal] KeyDown routine and Ctrl+Q

Jürgen Hestermann juergen.hestermann at gmx.de
Wed Feb 8 22:12:28 CET 2017


I use a KEYDOWN routine in my main TFORM to check for the key Ctrl+Q:

-----------------------------------------------------------------
procedure TForm1.FormKeyDown(Sender : TObject;
                          var Key    : Word;
                              Shift  : TShiftState);
begin // TForm1.FormKeyDown
case key of
    VK_Q :
       begin
       if Shift=[ssCtrl] then
          begin
          ....
-----------------------------------------------------------------

But when I type "Ctrl+Q" then "Key" is 17 instead of VK_Q (81).

If I now use 17 to trigger the "Q" key, then it is also triggered
when I just type the Ctrl-key (without any other key)!

This is all a bit weird.
How can I detect that "Ctrl+Q" is pressed without
getting fooled by any other key?




More information about the fpc-pascal mailing list