New to Telerik UI for ASP.NET AJAX? Download free 30-day trial


The OnClientKeyPressing client-side event occurs when any key is clicked while the TreeView is having the focus:

The event handler receives parameters:

  1. The TreeView instance that fired the event.

  2. Event arguments with functions:

  • get_node() retrieves a reference to the node which is selected before pressing the key.

  • get_domEvent() retrieves the DOM event.

  • set_cancel() - call this function to specify whether the event should be canceled (true) or not (false). Canceling the event will for example stop the keyboard navigation.

The example below shows how to toggle the nodes upon clicking the Enter key:

function OnClientKeyPressing(sender, args) {

    var node = args.get_node();
    var key = args.get_domEvent().keyCode;

    if (key == "13")
In this article