[Lazarus] How to detect that the Alt-key is released?
JuuS
JuuS at mykolab.ch
Sun Aug 2 14:33:29 CEST 2015
Hi,
"Shift" keys are handled differently. When you to to the declaration of
TShiftState you'll see:
TShiftStateEnum = (ssShift, ssAlt, ssCtrl,
ssLeft, ssRight, ssMiddle, ssDouble,
// Extra additions
ssMeta, ssSuper, ssHyper, ssAltGr, ssCaps, ssNum,
ssScroll,ssTriple,ssQuad,ssExtra1,ssExtra2);
TShiftState = set of TShiftStateEnum;
And you use it like:
if ssAlt in Shift then
showmessage( 'Yessss. Alt.' ).
(btw. this WON'T work in onkeyup with just the alt key...when you lift
alt (ie, keyup) it is no longer down and so is not in "Shift", to see it
work do something like alt-a).
or
if [ ssShift, ssCtrl ] * Shift = [] then
showmessage( 'shift or ctrl' );
play around with them, you'll get the results you want.
Also, you probably already know, be sure the form's keypreview property
is set to true.
Julius
On 08/02/2015 12:52 PM, Jürgen Hestermann wrote:
> According to http://wiki.lazarus.freepascal.org/LCL_Key_Handling
> the "KeyUp" event should be triggered when the Alt-key is released.
>
> But how do I tell this procedure that I want to check for the Alt-key?
> The "key" parameter is of type word.
> What is the representation of the Alt-key here?
> vk_alt does not exist.
>
> And how about the "Shift" parameter?
> It would tell me whether Alt is currently pressed or not
> but not whether it has been released.
>
> A bit confusing....
> Anybody knows how it works?
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
More information about the Lazarus
mailing list