Re: Handle / detect <Alt> key combinations

Jatin wrote:

Jamie wrote:

You keep changing your mind..
first you tell us that you need to detect, I gave you the API call.

then you tell us that isn't the problem, that you can detect that you need to simulate a combination of. I Gave you that.

now we're back to square 1..

I don't think you know what you want.. sorry..

Never mind, Jamie - probably I didn't articulate enough. Sorry about having confused you, and I thank you for still attempting to help me out in howsoever terse manner. But I think I was (am) pretty clear about what I wanted: how to detect <Alt><Ctrl><anykey> presses from WM_KEYDOWN or any appropriate message handler.

I really didn't get anywhere with this, so there is no question about getting back to square one.


procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
If Shift = [ssctrl,ssalt] then Caption:= Caption
+ Char(Key);


maybe this will give you some clues.

WM_KEYDOWN can only report one key at a time.
Delphi, helps this out by using the API's to build
the Shift variable for you ..

The VCL libs have this built into it other wise. YOu
need to process the WM_KEYDOWN message and if it is
a A..Z , then call the API GetKeyState..
In come controls Delphi also builds a cache, but I've found
that to not work so well.
For example, as the WM_KEYDOWN is coming in, it'll build a
Shift Variable setting the appropriate flag, when the WM_KEYUP
is sent in, It'll remove it from the shiftstate variable.
I suppose you could do the same thing but you need to process
both the WM_KEYDOWN and KEYUP to keep them in sync. Or ,simply
use the API call GetKeySTate(VK_ALT) for example.

TShiftState type

type TShiftState = set of (ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle, ssDouble);

remember that the KEY value here is only valid if it
falls with in the A..Z range other wise, it's just the
value of the ALT,CTRL etc. at the time unless you are
actually pressing down on a A..Z key..";