首页  编辑  

判断左右Shift

Tags: /超级猛料/Hardware.硬件相关/键盘和鼠标/   Date Created:

procedure WMKeyDown(var Message: TWMKEY); message WM_KEYDOWN;

   procedure WMKeyUp(var Message: TWMKEY); message WM_KEYUP;

 public

   { Public declarations }

 end;

var

 Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMKeyDown(var Message: TWMKey);

begin

    inherited;

    //判断按下

    if ((message.KeyData) and ($2a shl 16))=($2a shl 16) then

       showmessage('Left shift pressed')

    else if ((message.KeyData) and ($36 shl 16))=($36 shl 16) then

       showmessage('Right shift pressed');

end;

procedure TForm1.WMKeyUp(var Message: TWMKEY);

begin

    inherited;

    //判断抬起

    if ((message.KeyData) and ($2a shl 16)=($2a shl 16)) then

           showmessage('Left shift up')

    else if ((message.KeyData) and ($36 shl 16))=($36 shl 16) then

       showmessage('Right shift Up');

end;