ASPxClientTreeList.KeyDown Event
Occurs when a user presses a key while ASPxTreeList has focus.
Declaration
KeyDown: ASPxClientEvent<ASPxClientTreeListKeyboardEventHandler<ASPxClientTreeList>>
Event Data
The KeyDown event's data class is ASPxClientTreeListKeyboardEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
handled | Specifies whether to suppress the keyboard key’s default action. Inherited from ASPxClientGridKeyboardEventArgsBase. |
htmlEvent | Gets a DHTML event object that relates to the processed event. Inherited from ASPxClientGridKeyboardEventArgsBase. |
isAltPressed |
Specifies whether a user presses the Alt key when the event occurs.
Inherited from ASPxClientGridKeyboardEventArgsBase. |
isCtrlPressed |
Specifies whether a user presses the Ctrl key when the event occurs.
Inherited from ASPxClientGridKeyboardEventArgsBase. |
isShiftPressed |
Specifies whether a user presses the Shift key when the event occurs.
Inherited from ASPxClientGridKeyboardEventArgsBase. |
keyCode | Gets a key code. Inherited from ASPxClientGridKeyboardEventArgsBase. |
Remarks
Handle the KeyDown
event to process press actions for specific keys. To get information on the pressed key (for instance, its key or code value), use the e.htmlEvent property. You can also use the e.keyCode event property to get the key code as an integer value.
In the example below, ASPxTreeList allows users to press the custom Ctrl
+X
shortcut (the X
key’s integer code is 88) to export its data to a PDF document.
var xKeyCode = 88;
function onKeyDown(s, e) {
if (e.isCtrlPressed && e.keyCode == xKeyCode) {
s.ExportTo(ASPxClientTreeListExportFormat.Pdf);
}
}
<dx:ASPxTreeList ID="treeList" runat="server" ...>
<SettingsExport EnableClientSideExportAPI="true" />
<ClientSideEvents KeyDown="onKeyDown" />
<Columns>
<dx:TreeListDataColumn FieldName="DepartmentName" Caption="Department" />
<!--...-->
</Columns>
</dx:ASPxTreeList>
See Also