Create(Key: Integer; ShiftState: Integer);
Key is a code of the keyboard key.
ShiftState is a code of pressing the auxiliary keys (SHIFT, ALT and CTRL). Use ShiftState enumeration type to assign a desired value. If it is not necessary to use auxiliary keys, 0 should be passed as a value.
The Create constructor creates an argument of the OnKeyDown and OnKeyUp event.
Executing the example requires a form, a button named Button1 on it and the EditBox component named EditBox1. There is a handler of the OnKeyDown event for the EditBox1.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Argument: IKeyEventArgs;
Begin
Argument := New KeyEventArgs.Create(Keys.A, ShiftState.Shift);
EditBox1.OnKeyDown(EditBox1, Argument);
End Sub Button1OnClick;
After executing the example pressing the button generates the event of pressing the Shift+A keys in the area of the component for the EditBox1 component.
See also: