Send a key code to the server.
Syntax
object.SendKey( Key )
Parameters
- Key
- A value which specifies the key code to send to the server.
This may be a single byte, in which case it is sent to the server
as-is. If a numeric value is specified, then this is considered to
be an ASCII character value and it is sent to the server as a
single byte. The value must be between 1 and 255. If the key code
value is 0, then the method returns without sending any data. If
the value is greater than 255, an error will be raised. If the
Key argument is a string, then the method will send that
string to the server. An empty string is ignored and the method
will return without sending any data. An error will be returned if
the string is longer than 128 bytes.
Return Value
This method will return a value of true if the key code was
successfully sent to the server. If the key cannot be sent, the
method will return False and the LastError property will
contain the error code that indicates the reason for the failure.
This method will also return False if the key code value is zero or
an empty string is passed by the caller.
Remarks
The SendKey method sends a key code to the server.
This method is useful if the application needs to send a single
character to the server, as opposed to using the Write method
which should be used for sending large amounts of data.
The strings sent by the SendKey method are typically short
escape sequences which are generated by a terminal emulator when the
user presses a special key, such as a function key. For example, a
DEC VT100 terminal sends the escape sequence <ESC>[M when the
user presses the F1 function key. To simulate this, those three bytes
could be passed as the Key value.
Example
The following example demonstrates how to use the SendKey
method in conjunction with the KeyMapped and KeyPress
events in the Terminal Emulator control:
Private Sub Terminal1_KeyMapped(KeyIndex As Integer, Shift As Integer, KeyString As String)
TelnetClient1.SendKey KeyString
End Sub
Private Sub Terminal1_KeyPress(KeyAscii As Integer)
TelnetClient1.SendKey KeyAscii
End Sub
See Also
IsWritable Property,
Write Method,
OnWrite Event
|