procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (key=vk_control) and (shift=[ssDouble]) then memo1.Clear; end; 运行程序后按下Ctrl键并双击鼠标则清除Memo1中的内容,可是(shift=[ssDouble])不执行,为什么呀?谢谢!
----------------------------------------------
-
TKeyEvent = procedure (Sender: TObject; var Key: Word; Shift: TShiftState) of object;
property OnKeyDown: TKeyEvent;
Description
Use the OnKeyDown event handler to specify special processing to occur when a key is pressed. The OnKeyDown handler can respond to all keyboard keys, including function keys and keys combined with the Shift, Alt, and Ctrl keys, and pressed mouse buttons.
The TKeyEvent type points to a method that handles keyboard events.
The Key parameter is the key on the keyboard. For non-alphanumeric keys, use virtual key codes to determine the key pressed. For more information, see Virtual Key codes.
The Shift parameter indicates whether the Shift, Alt, or Ctrl keys are combined with the keystroke.
这是BORLAND中的帮助 写的
从最后一行看 SHIFT参数和鼠标无关
KEYDOWN事件 中不 截获 鼠标消息
只截获 键盘消息
而type TShiftState = set of (ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle, ssDouble); 中的真正有用 也经常使用的只有ssShift, ssAlt, ssCtrl,