简体   繁体   English

如何在Delphi中检测ctrl -t keypress

[英]How to detect ctrl-t keypress in Delphi

I have a Win32 form with a TEdit control. 我有一个带有TEdit控件的Win32表单。 When the user presses CTRL-t while the TEdit control is in focus, I want to detect it using the OnKeyUp event. 当用户在TEdit控件处于焦点时按下CTRL-t时,我想使用OnKeyUp事件检测它。 I need a code example, please, using the Key and/or Shift variables. 我需要一个代码示例,请使用Key和/或Shift变量。 Thanks. 谢谢。

Set KeyPreview of the form to True, then write this code for OnKeyUp event of your form: 将表单的KeyPreview设置为True,然后为表单的OnKeyUp事件编写此代码:

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if (Key = 84) and (Shift = [ssCtrl]) then
    ShowMessage('Ctrl+t is pressed!');
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM