The state of the Shift, Ctrl, Alt keys

106 51
< Continued from page 2

The following functions can be used to check if the Shift, Ctrl or Alt key(s) are pressed...

~~~~~~~~~~~~~~~~~~~~~~~~~
function CtrlDown : Boolean;
var
   State : TKeyboardState;
begin
   GetKeyboardState(State) ;
   Result := ((State[vk_Control] And 128) <> 0) ;
end;

function ShiftDown : Boolean;
var
   State : TKeyboardState;
begin
   GetKeyboardState(State) ;
   Result := ((State[vk_Shift] and 128) <> 0) ;
end;

function AltDown : Boolean;
var
   State : TKeyboardState;
begin
   GetKeyboardState(State) ;
   Result := ((State[vk_Menu] and 128) <> 0) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~


Delphi tips navigator:
» Hide a Process in the 'Close Program' Window
« Path shortener: c:\AB\C...DE\F.ghi

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.