Re: The escape key
- From: alanglloyd@xxxxxxx
- Date: 27 Aug 2005 23:25:37 -0700
Don't forget that OnKeyDown / OnKeyUp triggers with the _key_ which is
pressed, OnKeyPress triggers with the ASCII value which is the _result_
of the hardware key being pressed.
Hence if you want to know whether a _key_ has been activated use
OnKeyDown / Up. In those event handlers use Microsoft's VK_???
"virtual-key" constants.
If you want to check a key-press in OnKeyPress and also want to check
for modifiers (shift, control, alt) then use ...
if GetKeyState(VK_SHIFT {VK_CONTROL, VK_MENU}) < 0 then ...
.... as well as your ASCII key char value.
GetKeyState returns with the high bit set (ie is negative) if pressed.
For togglable keys (numlock, insert, scroll-lock) the low order bit is
set if the function is set.
Search help for "virtual-key codes" for a full list.
Note that (in D3 at least) the VK_A to VK_Z are not declared by Delphi
but are the ASCII values as returned by Ord() or used in Chr().
Alan Lloyd
.
- References:
- The escape key
- From: anthony
- Re: The escape key
- From: anthony
- The escape key
- Prev by Date: Button XP appearance
- Next by Date: Re: ActiveControl: how to use it?
- Previous by thread: Re: The escape key
- Next by thread: Tfont
- Index(es):