Wednesday, March 2, 2011

Do you have Hot Keys?

Defining and handling hot keys is very easy:

  • Set your form's "KeyPreview" property to "True."

    KeyPreview := True;

  • Define your form's "KeyDown" event. For example, following code will catch any CTRL+F1 [hot] key presses:

    procedure TForm1.FormKeyDown(
      Sender: TObject; var Key: Word;
      Shift: TShiftState );
      if( (ssCtrl in Shift) and
          (Key = VK_F1) )then
        // do your thing here...
        MessageBox( Handle,
          'F1 pressed!',
          'Hot Key',
          MB_OK );

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum