如何在Delphi中检测ctrl-t按键 [英] How to detect ctrl-t keypress in Delphi

查看:383
本文介绍了如何在Delphi中检测ctrl-t按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有TEdit控件的Win32表单。当用户在TEdit控件对焦时按下CTRL-t,我想使用OnKeyUp事件来检测它。我需要一个代码示例,请使用Key和/或Shift变量。谢谢。

解决方案

将表单的KeyPreview设置为True,然后为您的表单的OnKeyUp事件编写此代码:

 程序TForm1.FormKeyUp(发件人:TObject; var Key:Word; Shift:TShiftState); 
begin
if(Key = 84)和(Shift = [ssCtrl])然后
ShowMessage(Ctrl + t被按下!
结束


I have a Win32 form with a TEdit control. When the user presses CTRL-t while the TEdit control is in focus, I want to detect it using the OnKeyUp event. I need a code example, please, using the Key and/or Shift variables. Thanks.

解决方案

Set KeyPreview of the form to True, then write this code for OnKeyUp event of your form:

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

这篇关于如何在Delphi中检测ctrl-t按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆