KeyPress (Sender: TObject; var Key: Char);   当用户按下键盘上的字符键(字母,数字) 会触发该事件,功能键则不会(F1-F12,Ctrl,Alt,Shift)

KeyUp (Sender: TObject; var Key: Word;Shift: TShiftState);    当按下键盘上的按键松开时,会触发OnKeyUp事件(任意一个按键都会触发)

Keydown(Sender: TObject; var Key: Word;Shift: TShiftState);    按下任意一个按键都会触发该事件

 

KeyPress 和其他两个的区别是,Key 的取值是字符 ,其他的是数字(word  0·65535)

特别注意的是Shift:TShiftState  它的取值是:TShiftState = set of (ssShift, ssAlt, ssCtrl,ssLeft, ssRight, ssMiddle, ssDouble);  调用的例子有:

ssCtrl in Shift

或者

[ssCtrl]

 

Edit调用示例:

KeyPress

var
  key:char
begin
  key:='#13';
  EditKeyPress(nil,key);
end;

 

KeyUp

var
  key:word
begin
  key:=13;
  EditKeyUp(nil,key,[]);
end;

这里 shift 不取值,故写法 [ ]

 

Keydown

var
  key:word
begin
  key:=13;
  EditKeydown(nil,key,[]);
end;

  

 来源:https://www.cnblogs.com/guorongtao/p/11302949.html

 修改于:2019.08.15

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-06
  • 2021-05-21
  • 2021-12-09
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案