OnKeyDown Event

[Top]  [Chapter]  [Previous]  [Next]

Member of WPDLLInt


Declaration C#

KeyDown(KeyEventArgs e)


Here the standard event is used.


You need to cast e to wpKeyEventArgs which contains the properties Editor, Shift, Alt and Control.


private void wpdllInt1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)






Declaration OCX

OnKeyDown(ByVal Editor As Long, Key As Integer, ByVal Shift As Long)


This event is triggered when the user presses a key on the keyboard.




Editor:        The editor number, 1 or 2

Key:        The key board number as VK_ value

Shift:        A bit field representing the state of the control keys:

 1 : Shift key

 2 : ALT key

 4 : Ctrl key


Example VB6:


Private Sub WPDLLInt1_OnKeyDown(ByVal Editor As Long, Key As IntegerByVal Shift As Long)

  If Shift = 4 Then  

          ' Ctrl+B

          If Key = Asc("B") Then

                     WPDLLInt1.TextAttr.ToggleStyle (0)

          ' Ctrl+I

          ElseIf Key = Asc("I") Then

                     WPDLLInt1.TextAttr.ToggleStyle (1)

          ' Ctrl+U

          ElseIf Key = Asc("U") Then

                     WPDLLInt1.TextAttr.ToggleStyle (2)

          End If  

  End If

End Sub


Trouble shooting:

If your code does not work please check if you have a global short cut which reverts the change.

[idh_wpdllint_onkeydown.htm]    Copyright © 2007 by WPCubed GmbH