procedure TSell.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (Msg.Message=WM_KEYDOWN)and(Msg.wParam=VK_CONTROL+VK_HOME)then
begin
end;
to check the status of the VK_CONTROL virtual key, you must use the GetKeyState
function.
try this sample
procedure TSell.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if (Msg.Message=WM_KEYDOWN) then
if (GetKeyState(VK_CONTROL) < 0) and (Msg.wParam=VK_HOME) then
//do your stuff
end;
VK_CONTROL
+ VK_HOME
= 17 + 36 = 53 = Ord('5')
. You're checking whether the user has pressed 5 along the top row of the keyboard. (Isn't that what you wanted? Your question didn't say.)
You can't just add the virtual-key codes of two independent keys to discover whether they're both being pressed simultaneously. Ctrl and Home are two different keys, and each one generates its own wm_KeyDown
and wm_KeyUp
messages. (But don't try to detect the pressing of both those keys in sequence. It will get far more complicated than you want. Detect when Home is pressed, and then use GetKeyState
, like Rruz's answer demonstrates, to detect whether Ctrl was already down at the time you received the current keyboard message.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With