Visual Basic (Declaration) | |
---|---|
Public Shadows Event KeyDown As KeyDownHandler |
Visual Basic (Usage) | ![]() |
---|---|
Dim instance As Vt Dim handler As KeyDownHandler AddHandler instance.KeyDown, handler |
C# | |
---|---|
public new event KeyDownHandler KeyDown |
Managed Extensions for C++ | |
---|---|
public: new __event KeyDownHandler* KeyDown |
C++/CLI | |
---|---|
public: new event KeyDownHandler^ KeyDown |
The event handler receives an argument of type VtKeyEventArgs containing data related to this event. The following VtKeyEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Alt (Inherited from System.Windows.Forms.KeyEventArgs) | |
Control (Inherited from System.Windows.Forms.KeyEventArgs) | |
Extended | Returns true when the generating key is on an extended part of the keyboard. |
Handled (Inherited from System.Windows.Forms.KeyEventArgs) | |
KeyCode (Inherited from System.Windows.Forms.KeyEventArgs) | |
KeyData (Inherited from System.Windows.Forms.KeyEventArgs) | |
KeyValue (Inherited from System.Windows.Forms.KeyEventArgs) | |
Modifiers (Inherited from System.Windows.Forms.KeyEventArgs) | |
Shift (Inherited from System.Windows.Forms.KeyEventArgs) | |
SuppressKeyPress (Inherited from System.Windows.Forms.KeyEventArgs) |
In the following example, the string "Hello World!" is mapped to Ctrl-H.
C# | ![]() |
---|---|
private void vt1_KeyDown(object sender, Dart.Emulation.VtKeyEventArgs e) { //If there is a telnet connection if (telnet1.State != Dart.Common.ConnectionState.Closed) { //Send substitute string when Control-H pressed if (e.Control && e.KeyCode == Keys.H) { e.Handled = true; //prevent other key events telnet1.Write("Hello World!"); } } } |
Visual Basic | ![]() |
---|---|
Private Sub vt1_KeyDown(ByVal sender As Object, ByVal e As Dart.Emulation.VtKeyEventArgs) 'If there is a telnet connection If telnet1.State <> Dart.Common.ConnectionState.Closed Then 'Send substitute string when Control-H pressed If e.Control AndAlso e.KeyCode = Keys.H Then e.Handled = True 'prevent other key events telnet1.Write("Hello World!") End If End If End Sub |
The KeyDown event is raised when a key is pressed and before the KeyPress event is raised. This event is useful for performing keymapping (mapping individual keys to any arbitrary character sequence). To do this, simply set e.Handled to true (notifying the Vt control that the key press was handled so the Vt control does not raise the KeyDown event) and send your own substituted character sequence.
Target Platforms: Microsoft .NET Framework 2.0