00 Votes

Delphi/Lazarus: Determine ShiftState

Question by Guest | 2016-04-30 at 22:54

When creating a procedure such as OnKeyDown, OnKeyPress, OnMouseDown, OnMouseMove or OnMouseUp in Delphi or Lazarus, there is always a variable called Shift of the type TShiftState available, holding the recent state of the keys CTRL, ALT and SHIFT and even some information about the current mouse keys.

However, this information is not available in most of the other procedures (OnClick, OnDblClick, OnKeyPress, OnMouseLeave etc). What can I do to make the current shift state also available in those procedures or even at an arbitrary other point of my program code?

ReplyPositiveNegative
Avatar
1Best Answer1 Vote

You can always fetch the current state of ShiftState by using the function GetKeyShiftState.

Here is an example:

procedure ArbitraryProcedure;
var
  AShiftState: TShiftState;
begin    
  AShiftState := GetKeyShiftState;
 
  if ssCtrl in AShiftState then ShowMessage('STRG');
end;

More information about the ShiftState, you can get here.
2016-04-30 at 22:56

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.