[fpc-pascal] KeyDown routine and Ctrl+Q
Vojtěch Čihák
vojtech.cihak at atlas.cz
Wed Feb 8 23:26:05 CET 2017
Hi,
when you press CTRL+Q you will obtain two OnKeyDown events. The first with Key=17 (it is CTRL) and the second with Key=81 (Q). Both events will have ssCtrl in Shift.
V.
______________________________________________________________
> Od: Jürgen Hestermann <juergen.hestermann at gmx.de>
> Komu: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> Datum: 08.02.2017 22:12
> Předmět: [fpc-pascal] KeyDown routine and Ctrl+Q
>
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?
_______________________________________________
fpc-pascal maillist - fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170208/570f035d/attachment.html>
More information about the fpc-pascal
mailing list