简体   繁体   中英

How to detect ctrl-t keypress in Delphi

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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