[fpc-pascal] KeyDown routine and Ctrl+Q

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Thu Feb 9 09:32:19 CET 2017


On 08/02/17 21:30, Jürgen Hestermann wrote:
> 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?

Watch out for operating systems which still handle ^S ^Q and possibly ^P 
specially. I was painfully reminded of this the other day when I hit ^S 
in an SSH session and everything ground to a halt.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list