Detect rigth/left shift key

Posted in Manipulators

Use GetKeyNameText function. For example:

type
  TForm1 = class(TForm)
    Label1: TLabel;
  private
    procedure MyMessage(var Msg: TWMKeyDown); message WM_KEYDOWN;
    { Private declarations }
  public
    { Public declarations }
  end;
...
procedure TForm1.MyMessage(var Msg: TWMKeyDown);
var
  P: PCHar;
begin
  P:=StrAlloc(150);
  if Msg.CharCode=16 then
    GetKeyNameText(Msg.KeyData, P, 150)
  else StrPCopy(P, 'Other Key');
  Label1.Caption:=StrPas(P);
end;