STK X Send comments on this topic.
KeyDown Event (AgUiAxGfxAnalysisCntrl)
See Also  Example
KeyCode
A key code such as System.Windows.Forms.Keys.F1 (the F1 key) or System.Windows.Forms.Keys.Home (the HOME key) in Visual Basic .NET).
Shift
An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of Shift is 6.





Description

Occurs when the user presses a key while the control has the focus.

Syntax

[Visual Basic .NET]
Public Event KeyDown( _
   ByRef KeyCode As Integer, _
   ByVal Shift As Integer _
)

[C#]
public void KeyDown(
ref int KeyCode,
int Shift
);

[Managed C++]
public: void KeyDown(
int ^ KeyCode,
int Shift
);

[Java]
public  keyDown(
ppInteger KeyCode,
ppInteger Shift
);

[Unmanaged C++]
public: HRESULT KeyDown(
int * KeyCode,
int Shift
);

Parameters

KeyCode
A key code such as System.Windows.Forms.Keys.F1 (the F1 key) or System.Windows.Forms.Keys.Home (the HOME key) in Visual Basic .NET).
Shift
An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Remarks

Although the KeyDown events can apply to most keys, it is most often used for:

  • Extended character keys such as function keys.
  • Navigation keys.
  • Combinations of keys with standard keyboard modifiers.
  • Distinguishing between the numeric keypad and regular number keys.

KeyDown is not invoked for the TAB key.

KeyDown interpret the uppercase and lowercase of each character by means of two arguments: KeyCode, which indicates the physical key (thus returning A and a as the same key) and Shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the Shift argument, you can use the AgEShiftValues constants which define the bits within the argument. The constants act as bit masks that you can use to test for any combination of keys.

In VB.NET the KeyDown event is shown as  "xxxxxxxx_KeyDownEvent" in the IDE.

Example

[Visual Basic .NET] Copy Code
Private Sub AxAgUiAxGfxAnalysisCntrl1_KeyDownEvent( _
                            ByVal sender As Object, _
                            ByVal e As AxAGI.STKX.IAgUiAxGfxAnalysisCntrlEvents_KeyDownEvent) _
                  Handles AxAgUiAxGfxAnalysisCntrl1.KeyDownEvent

    If (e.keyCode = System.Windows.Forms.Keys.A) And ((e.shift And AGI.STKX.AgEShiftValues.eCtrlPressed) > 0)
        ' CTRL-a has been key is down!
        ...
    End If

End Sub

See Also

© 2016 Analytical Graphics, Inc. All Rights Reserved.

STK Programming Interface 11.0.1