[Lazarus] How to detect that the Alt-key is released?
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@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to detect that the Alt-key is released?
Am 2015-08-02 um 14:33 schrieb JuuS: (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). But that's just what I want: Detect the release of the Alt+key (independend from other keys state). So it's not possible? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to detect that the Alt-key is released?
Sorry I confused you, my specialty. What I meant was if you use the 'ssAlt in Shift' line, it won't work if you only press the alt key because in a keyup handler the key is then up! And so won't pass the if statement. It would work in a keydown handler though. if you press and hold alt and then press and release, for example, 'a' you will see it catch the state of the alt key. as to the vk_menu, no idea. But to detect states of shift, control, alt, etc. the methods I showed are what is normally used. On 08/02/2015 02:42 PM, Jürgen Hestermann wrote: Am 2015-08-02 um 14:33 schrieb JuuS: (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). But that's just what I want: Detect the release of the Alt+key (independend from other keys state). So it's not possible? -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] How to detect that the Alt-key is released?
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( 'Ye. 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@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus