Monday, March 10, 2008

How to detect the state of the Shift, Ctrl, Alt keys

Source: http://delphi.about.com/cs/adptips2000/a/bltip0400_3.htm

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;


Looking for last minute shopping deals? Find them fast with Yahoo! Search.

0 Comments: