event KeyDown (ByRef KeyCode as Integer, Shift as Integer)
Occurs when the user presses a key while an object has the focus.

TypeDescription
KeyCode as Integer (By Reference) An integer that represent the key code
Shift as Integer 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.
Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key. You test for a condition by first assigning each result to a temporary integer variable and then comparing shift to a bit mask. The control fires the Change event when the user alters the control's content. Use the And operator with the shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, as in this example:
ShiftDown = (Shift And 1) > 0
CtrlDown = (Shift And 2) > 0
AltDown = (Shift And 4) > 0

In a procedure, you can test for any combination of conditions, as in this example:
If AltDown And CtrlDown Then

Syntax for KeyDown event, /NET version, on:

private void KeyDown(object sender,ref short KeyCode,short Shift)
{
}

Private Sub KeyDown(ByVal sender As System.Object,ByRef KeyCode As Short,ByVal Shift As Short) Handles KeyDown
End Sub

Syntax for KeyDown event, /COM version, on:

private void KeyDownEvent(object sender, AxEXHTMLLib._IHTMLEvents_KeyDownEvent e)
{
}

void OnKeyDown(short FAR* KeyCode,short Shift)
{
}

void __fastcall KeyDown(TObject *Sender,short * KeyCode,short Shift)
{
}

procedure KeyDown(ASender: TObject; var KeyCode : Smallint;Shift : Smallint);
begin
end;

procedure KeyDownEvent(sender: System.Object; e: AxEXHTMLLib._IHTMLEvents_KeyDownEvent);
begin
end;

begin event KeyDown(integer KeyCode,integer Shift)
end event KeyDown

Private Sub KeyDownEvent(ByVal sender As System.Object, ByVal e As AxEXHTMLLib._IHTMLEvents_KeyDownEvent) Handles KeyDownEvent
End Sub

Private Sub KeyDown(KeyCode As Integer,Shift As Integer)
End Sub

Private Sub KeyDown(KeyCode As Integer,ByVal Shift As Integer)
End Sub

LPARAMETERS KeyCode,Shift

PROCEDURE OnKeyDown(oHTML,KeyCode,Shift)
RETURN

Syntax for KeyDown event, /COM version (others), on:

<SCRIPT EVENT="KeyDown(KeyCode,Shift)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function KeyDown(KeyCode,Shift)
End Function
</SCRIPT>

Procedure OnComKeyDown Short llKeyCode Short llShift
	Forward Send OnComKeyDown llKeyCode llShift
End_Procedure

METHOD OCX_KeyDown(KeyCode,Shift) CLASS MainDialog
RETURN NIL

void onEvent_KeyDown(COMVariant /*short*/ _KeyCode,int _Shift)
{
}

function KeyDown as v (KeyCode as N,Shift as N)
end function

function nativeObject_KeyDown(KeyCode,Shift)
return

The following VB sample applies the red color to the current selection when user presses the CTRL + J:

Private Const WM_COMMAND = &H111
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Sub HTML1_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyJ) And (Shift = 2) Then
        SendMessage HTML1.hwnd, WM_COMMAND, &HE15C * 65536, 0
    End If
End Sub

The known commands are listed bellow:

#define ID_HTMLEDIT_LABELFORMATIMAGE			0xE108
#define ID_HTMLEDIT_FORMATLABELMISC			0xE109
#define ID_HTMLEDIT_FORMATSEPFONT			0xE110
#define ID_HTMLEDIT_FORMATLABELFONT			0xE111
#define ID_HTMLEDIT_FORMATSEPCOLOR			0xE111
#define ID_HTMLEDIT_FORMATLABELCOLOR			0xE112
#define ID_HTMLEDIT_FORMATOFFSETGROUP			0xE112
#define ID_HTMLEDIT_LABELFORMATALIGN			0xE113
#define ID_HTMLEDIT_SEPTYPE			0xE114
#define ID_HTMLEDIT_SEPSTANDARDGDI			0xE115
#define ID_HTMLEDIT_LABELTYPE			0xE116
#define ID_HTMLEDIT_LABELFORMAT			0xE117
#define ID_HTMLEDIT_LABELEDIT			0xE118
#define ID_HTMLEDIT_LABELCOMMAND			0xE119
#define ID_HTMLEDIT_DELETE			0xE120
#define ID_HTMLEDIT_COPY				0xE122
#define ID_HTMLEDIT_CUT				0xE123
#define ID_HTMLEDIT_FIND				0xE124
#define ID_HTMLEDIT_PASTE				0xE125
#define ID_HTMLEDIT_REPLACE			0xE129
#define ID_HTMLEDIT_SELECT_ALL			0xE12A
#define ID_HTMLEDIT_UNDO				0xE12B
#define ID_HTMLEDIT_REDO				0xE12C
#define ID_HTMLEDIT_FINDNEXT			0xE12D
#define ID_HTMLEDIT_FINDPREV			0xE12E
#define ID_HTMLEDIT_FORMAT			0xE12F
#define ID_HTMLEDIT_FORMATBOLD			0xE130
#define ID_HTMLEDIT_FORMATITALIC			0xE131
#define ID_HTMLEDIT_FORMATUNDERLINE			0xE132
#define ID_HTMLEDIT_FORMATSTRIKEOUT			0xE133
#define ID_HTMLEDIT_FORMATFGCOLOR			0xE134
#define ID_HTMLEDIT_FORMATBGCOLOR			0xE135
#define ID_HTMLEDIT_FORMATALIGN			0xE136
#define ID_HTMLEDIT_FORMATLEFT			0xE137
#define ID_HTMLEDIT_FORMATCENTER			0xE138
#define ID_HTMLEDIT_FORMATRIGHT			0xE139
#define ID_HTMLEDIT_FORMATLINE			0xE140
#define ID_HTMLEDIT_FORMATLINENONE			0xE14A
#define ID_HTMLEDIT_FORMATLINESOLID			0xE14B
#define ID_HTMLEDIT_FORMATLINEDOT			0xE14C
#define ID_HTMLEDIT_FORMATLINEUP			0xE14D
#define ID_HTMLEDIT_FORMATLINEDOWN			0xE14E
#define ID_HTMLEDIT_FORMATIMAGE			0xE14F
#define ID_HTMLEDIT_FORMATIMAGESIZE			0xE150
#define ID_HTMLEDIT_FORMATIMAGESIZESMALLER		0xE151
#define ID_HTMLEDIT_FORMATIMAGESIZEDEFAULT		0xE152
#define ID_HTMLEDIT_FORMATIMAGESIZEBIGGER		0xE153
#define ID_HTMLEDIT_FORMATCOLORS			0xE154
#define ID_HTMLEDIT_FORMATFORECOLOR			0xE155
#define ID_HTMLEDIT_FORMATBACKCOLOR			0xE156
#define ID_HTMLEDIT_FORMATFORECOLORDEFAULT		0xE157
#define ID_HTMLEDIT_FORMATBACKCOLORDEFAULT		0xE158
#define ID_HTMLEDIT_FORMATFORECOLORWHITE		0xE159
#define ID_HTMLEDIT_FORMATFORECOLORBLACK		0xE15A
#define ID_HTMLEDIT_FORMATFORECOLORGRAY		0xE15B
#define ID_HTMLEDIT_FORMATFORECOLORRED			0xE15C
#define ID_HTMLEDIT_FORMATFORECOLORGREEN		0xE15D
#define ID_HTMLEDIT_FORMATFORECOLORBLUE		0xE15E
#define ID_HTMLEDIT_FORMATBACKCOLORWHITE		0xE15F
#define ID_HTMLEDIT_FORMATBACKCOLORBLACK		0xE160
#define ID_HTMLEDIT_FORMATBACKCOLORGRAY		0xE161
#define ID_HTMLEDIT_FORMATBACKCOLORRED			0xE162
#define ID_HTMLEDIT_FORMATBACKCOLORGREEN		0xE163
#define ID_HTMLEDIT_FORMATBACKCOLORBLUE		0xE164
#define ID_HTMLEDIT_FORMATFONT			0xE165
#define ID_HTMLEDIT_FORMATFONTSIZE			0xE166
#define ID_HTMLEDIT_FORMATFONTDEFAULT			0xE167
#define ID_HTMLEDIT_FORMATFONTSIZESMALLER		0xE168
#define ID_HTMLEDIT_FORMATFONTSIZEDEFAULT		0xE169
#define ID_HTMLEDIT_FORMATFONTSIZELARGER		0xE16A
#define ID_HTMLEDIT_FORMATFONTFACE			0xE16B
#define ID_HTMLEDIT_FORMATFONTFACEDEFAULT		0xE16C
#define ID_HTMLEDIT_FORMATOFFSET			0xE16D
#define ID_HTMLEDIT_FORMATOFFSETUPPER			0xE16E
#define ID_HTMLEDIT_FORMATOFFSETDEFAULT		0xE16F
#define ID_HTMLEDIT_FORMATOFFSETLOWER			0xE170
#define ID_HTMLEDIT_FORMATDECORATIVE			0xE171
#define ID_HTMLEDIT_FORMATDECORATIVEDEFAULT		0xE172
#define ID_HTMLEDIT_FORMATGRADIENT			0xE173
#define ID_HTMLEDIT_FORMATGRADIENTNONE			0xE174
#define ID_HTMLEDIT_FORMATGRADIENTCOLOR		0xE175
#define ID_HTMLEDIT_FORMATGRADIENTCOLORWHITE		0xE176
#define ID_HTMLEDIT_FORMATGRADIENTCOLORBLACK		0xE177
#define ID_HTMLEDIT_FORMATGRADIENTCOLORGRAY		0xE178
#define ID_HTMLEDIT_FORMATGRADIENTCOLORRED		0xE179
#define ID_HTMLEDIT_FORMATGRADIENTCOLORGREEN		0xE17A
#define ID_HTMLEDIT_FORMATGRADIENTCOLORBLUE		0xE17B
#define ID_HTMLEDIT_FORMATGRADIENTMODE			0xE17C
#define ID_HTMLEDIT_FORMAGRADIENTMODEHORIZONTAL		0xE17D
#define ID_HTMLEDIT_FORMAGRADIENTMODEVERTICAL		0xE17E
#define ID_HTMLEDIT_FORMAGRADIENTMODEFORWARDDIAGONAL	0xE17F
#define ID_HTMLEDIT_FORMAGRADIENTMODEBACKWARDDIAGONAL	0xE180
#define ID_HTMLEDIT_FORMAGRADIENTBLENDTRIANGULARSHAPE	0xE181
#define ID_HTMLEDIT_FORMATOUTLINE			0xE182
#define ID_HTMLEDIT_FORMATOUTLINENONE			0xE183
#define ID_HTMLEDIT_FORMATOUTLINECOLOR			0xE184
#define ID_HTMLEDIT_FORMATOUTLINECOLORWHITE		0xE185
#define ID_HTMLEDIT_FORMATOUTLINECOLORBLACK		0xE186
#define ID_HTMLEDIT_FORMATOUTLINECOLORGRAY		0xE187
#define ID_HTMLEDIT_FORMATOUTLINECOLORRED		0xE188
#define ID_HTMLEDIT_FORMATOUTLINECOLORGREEN		0xE189
#define ID_HTMLEDIT_FORMATOUTLINECOLORBLUE		0xE18A
#define ID_HTMLEDIT_FORMATOUTLINEWIDTH			0xE18B
#define ID_HTMLEDIT_FORMATOUTLINEWIDTHSMALLER		0xE18C
#define ID_HTMLEDIT_FORMATOUTLINEWIDTHDEFAULT		0xE18D
#define ID_HTMLEDIT_FORMATOUTLINEWIDTHLARGER		0xE18E
#define ID_HTMLEDIT_FORMATSHADOW			0xE18F
#define ID_HTMLEDIT_FORMATSHADOWNONE			0xE190
#define ID_HTMLEDIT_FORMATSHADOWCOLOR			0xE191
#define ID_HTMLEDIT_FORMATSHADOWCOLORWHITE		0xE192
#define ID_HTMLEDIT_FORMATSHADOWCOLORBLACK		0xE193
#define ID_HTMLEDIT_FORMATSHADOWCOLORGRAY		0xE194
#define ID_HTMLEDIT_FORMATSHADOWCOLORRED		0xE195
#define ID_HTMLEDIT_FORMATSHADOWCOLORGREEN		0xE196
#define ID_HTMLEDIT_FORMATSHADOWCOLORBLUE		0xE197
#define ID_HTMLEDIT_FORMATSHADOWOFFSET			0xE198
#define ID_HTMLEDIT_FORMATSHADOWOFFSETSMALLER		0xE199
#define ID_HTMLEDIT_FORMATSHADOWOFFSETDEFAULT		0xE19A
#define ID_HTMLEDIT_FORMATSHADOWOFFSETLARGER		0xE19B
#define ID_HTMLEDIT_FORMATSHADOWWIDTH			0xE19C
#define ID_HTMLEDIT_FORMATSHADOWWIDTHSMALLER		0xE19D
#define ID_HTMLEDIT_FORMATSHADOWWIDTHDEFAULT		0xE19E
#define ID_HTMLEDIT_FORMATSHADOWWIDTHLARGER		0xE19F
#define ID_HTMLEDIT_FORMATHYPERLINK			0xE1A0
#define ID_HTMLEDIT_FORMATHYPERLINKID			0xE1A1
#define ID_HTMLEDIT_FORMATHYPERLINKOPTIONS		0xE1A2
#define ID_HTMLEDIT_FORMATREPLACESEL			0xE1A3

#define ID_HTMLEDIT_FORMATFONTFACEENUM			0xD000
#define ID_HTMLEDIT_FORMATINSERTIMAGE			0xF000
#define ID_HTMLEDIT_INCREMENTALSEARCH			0xEA02