Pls see the following codes:
void __fastcall TForm1::FormKeyDown(TObject *Sender,WORD &Key,TShiftState Shift)
{
if(Key=='F' && Shift.Contains(ssCtrl))
{
//add your code here
.....
}
}
Use the OnKeyDown event handler to specify special processing to occur when a key is pressed. The OnKeyDown handler can respond to all keyboard keys, including function keys and keys combined with the Shift, Alt, and Ctrl keys, and pressed mouse buttons.
The TKeyEvent type points to a method that handles keyboard events.
The Key parameter is the key on the keyboard. For non-alphanumeric keys, use WinAPI virtual key codes to determine the key pressed. For more information, see Virtual Key codes.
The Shift parameter indicates whether the Shift, Alt, or Ctrl keys are combined with the keystroke.
Shift参数的含义如下:
Value Meaning
ssShift The Shift key is held down.
ssAlt The Alt key is held down.
ssCtrl The Ctrl key is held down.
ssLeft The left mouse button is held down.
ssRight The right mouse button is held down.
ssMiddle The middle mouse button is held down.
ssDouble The mouse was double-clicked.