# Custom Key Handling

Some of the Telerik UI for ASP.NET MVC wrappers expose the `KendoKeydown` event. You can use this event to:

* **Override** a built-in key or key combination by blocking the default behavior and replacing it with your own logic.
* **Add** new key combinations that the component does not handle out of the box.

## How the KendoKeydown Event Works

The event argument exposes the following relevant properties:

| Property                | Type    | Description                                                                                         |
| ----------------------- | ------- | --------------------------------------------------------------------------------------------------- |
| `e.sender`              | Object  | The client-side component instance.                                                                 |
| `e.keyCode`             | Number  | The code of the pressed key. Use `kendo.keys` constants for readable comparisons.                   |
| `e.ctrlKey`             | Boolean | `true` when `Ctrl` is held.                                                                         |
| `e.shiftKey`            | Boolean | `true` when `Shift` is held.                                                                        |
| `e.altKey`              | Boolean | `true` when `Alt` is held.                                                                          |
| `e.preventKendoKeydown` | Boolean | Set to `true` to prevent the component from running its default keydown handler for this key press. |

## Supported Components

The following wrappers support the `KendoKeydown` event:

| Component                                                                                                                                    | Key Handling Article                                                                                                                                                                  |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ActionSheet](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/actionsheet/accessibility/overview)                   | [Custom Key Handling in ActionSheet](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/actionsheet/accessibility/custom-keyboard-navigation)                   |
| [AIPrompt](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/conversational-ui/aiprompt/accessibility/overview)                  | [Custom Key Handling in AIPrompt](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/conversational-ui/aiprompt/accessibility/custom-keyboard-navigation)                  |
| [AutoComplete](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/accessibility/overview)                    | [Custom Key Handling in AutoComplete](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/accessibility/custom-keyboard-navigation)                    |
| [BottomNavigation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/bottomnavigation/accessibility/overview)         | [Custom Key Handling in BottomNavigation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/bottomnavigation/accessibility/custom-keyboard-navigation)         |
| [Button](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/button/accessibility/overview)                             | [Custom Key Handling in Button](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/button/accessibility/custom-keyboard-navigation)                             |
| [ButtonGroup](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/buttongroup/accessibility/overview)                   | [Custom Key Handling in ButtonGroup](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/buttongroup/accessibility/custom-keyboard-navigation)                   |
| [Calendar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/calendar/accessibility/overview)                         | [Custom Key Handling in Calendar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/calendar/accessibility/custom-keyboard-navigation)                         |
| [Chart Wizard](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/chartwizard/accessibility/overview)                             | [Custom Key Handling in Chart Wizard](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/chartwizard/accessibility/custom-keyboard-navigation)                             |
| [Chip](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/chip/accessibility/overview)                                 | [Custom Key Handling in Chip](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/chip/accessibility/custom-keyboard-navigation)                                 |
| [ChipList](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/chiplist/accessibility/overview)                         | [Custom Key Handling in ChipList](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/chiplist/accessibility/custom-keyboard-navigation)                         |
| [ColorPicker](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/colorpicker/accessibility/overview)                      | [Custom Key Handling in ColorPicker](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/colorpicker/accessibility/custom-keyboard-navigation)                      |
| [ComboBox](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/combobox/accessibility/overview)                            | [Custom Key Handling in ComboBox](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/combobox/accessibility/custom-keyboard-navigation)                            |
| [DateInput](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/dateinput/accessibility/overview)                          | [Custom Key Handling in DateInput](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/dateinput/accessibility/custom-keyboard-navigation)                          |
| [Dialog](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/dialog/accessibility/overview)                                 | [Custom Key Handling in Dialog](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/dialog/accessibility/custom-keyboard-navigation)                                 |
| [Drawer](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/drawer/accessibility/overview)                             | [Custom Key Handling in Drawer](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/drawer/accessibility/custom-keyboard-navigation)                             |
| [DropDownList](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/dropdownlist/accessibility/overview)                    | [Custom Key Handling in DropDownList](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/dropdownlist/accessibility/custom-keyboard-navigation)                    |
| [DropDownTree](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/dropdowntree/accessibility/overview)                    | [Custom Key Handling in DropDownTree](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/dropdowntree/accessibility/custom-keyboard-navigation)                    |
| [ExpansionPanel](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/expansionpanel/accessibility/overview)                 | [Custom Key Handling in ExpansionPanel](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/expansionpanel/accessibility/custom-keyboard-navigation)                 |
| [Filter](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/filter/accessibility/overview)                        | [Custom Key Handling in Filter](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/filter/accessibility/custom-keyboard-navigation)                        |
| [FloatingActionButton](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/floatingactionbutton/accessibility/overview) | [Custom Key Handling in FloatingActionButton](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/floatingactionbutton/accessibility/custom-keyboard-navigation) |
| [Gantt](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/gantt/accessibility/overview)                               | [Custom Key Handling in Gantt](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/gantt/accessibility/custom-keyboard-navigation)                               |
| [Grid](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/accessibility/overview)                            | [Custom Key Handling in Grid](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/grid/accessibility/custom-keyboard-navigation)                            |
| [ImageEditor](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/imageeditor/accessibility/overview)                      | [Custom Key Handling in ImageEditor](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/imageeditor/accessibility/custom-keyboard-navigation)                      |
| [InlineAIPrompt](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/conversational-ui/inline-aiprompt/accessibility/overview)     | [Custom Key Handling in InlineAIPrompt](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/conversational-ui/inline-aiprompt/accessibility/custom-keyboard-navigation)     |
| [ListBox](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/listbox/accessibility/overview)                              | [Custom Key Handling in ListBox](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/listbox/accessibility/custom-keyboard-navigation)                              |
| [ListView](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/listview/accessibility/overview)                    | [Custom Key Handling in ListView](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/listview/accessibility/custom-keyboard-navigation)                    |
| [MediaPlayer](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/media/mediaplayer/accessibility/overview)                        | [Custom Key Handling in MediaPlayer](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/media/mediaplayer/accessibility/custom-keyboard-navigation)                        |
| [Menu](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/menu/accessibility/overview)                                 | [Custom Key Handling in Menu](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/menu/accessibility/custom-keyboard-navigation)                                 |
| [MultiSelect](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/multiselect/accessibility/overview)                      | [Custom Key Handling in MultiSelect](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/multiselect/accessibility/custom-keyboard-navigation)                      |
| [MultiViewCalendar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/multiviewcalendar/accessibility/overview)       | [Custom Key Handling in MultiViewCalendar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/multiviewcalendar/accessibility/custom-keyboard-navigation)       |
| [NumericTextBox](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/numerictextbox/accessibility/overview)                | [Custom Key Handling in NumericTextBox](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/numerictextbox/accessibility/custom-keyboard-navigation)                |
| [OrgChart](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/diagrams-and-maps/orgchart/accessibility/overview)                  | [Custom Key Handling in OrgChart](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/diagrams-and-maps/orgchart/accessibility/custom-keyboard-navigation)                  |
| [OTPInput](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/otpinput/accessibility/overview)                            | [Custom Key Handling in OTPInput](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/otpinput/accessibility/custom-keyboard-navigation)                            |
| [Pager](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/pager/accessibility/overview)                          | [Custom Key Handling in Pager](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/pager/accessibility/custom-keyboard-navigation)                          |
| [PanelBar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/panelbar/accessibility/overview)                         | [Custom Key Handling in PanelBar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/panelbar/accessibility/custom-keyboard-navigation)                         |
| [PDFViewer](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/pdf/pdfviewer/accessibility/overview)                              | [Custom Key Handling in PDFViewer](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/pdf/pdfviewer/accessibility/custom-keyboard-navigation)                              |
| [PropertyGrid](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/propertygrid/accessibility/overview)            | [Custom Key Handling in PropertyGrid](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/propertygrid/accessibility/custom-keyboard-navigation)            |
| [Rating](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/rating/accessibility/overview)                                | [Custom Key Handling in Rating](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/rating/accessibility/custom-keyboard-navigation)                                |
| [Scheduler](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/scheduler/accessibility/overview)                       | [Custom Key Handling in Scheduler](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/scheduler/accessibility/custom-keyboard-navigation)                       |
| [Slider](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/slider/accessibility/overview)                                | [Custom Key Handling in Slider](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/slider/accessibility/custom-keyboard-navigation)                                |
| [SpeechToTextButton](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/speechtotextbutton/accessibility/overview)     | [Custom Key Handling in SpeechToTextButton](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/speechtotextbutton/accessibility/custom-keyboard-navigation)     |
| [Splitter](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/splitter/accessibility/overview)                             | [Custom Key Handling in Splitter](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/splitter/accessibility/custom-keyboard-navigation)                             |
| [Spreadsheet](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/spreadsheet/accessibility/overview)              | [Custom Key Handling in Spreadsheet](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/spreadsheet/accessibility/custom-keyboard-navigation)              |
| [Stepper](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/stepper/accessibility/overview)                           | [Custom Key Handling in Stepper](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/stepper/accessibility/custom-keyboard-navigation)                           |
| [Switch](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/switch/accessibility/overview)                                | [Custom Key Handling in Switch](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/switch/accessibility/custom-keyboard-navigation)                                |
| [TileLayout](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/tilelayout/accessibility/overview)                         | [Custom Key Handling in TileLayout](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/tilelayout/accessibility/custom-keyboard-navigation)                         |
| [TimeDurationPicker](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/timedurationpicker/accessibility/overview)        | [Custom Key Handling in TimeDurationPicker](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/timedurationpicker/accessibility/custom-keyboard-navigation)        |
| [Timeline](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/timeline/accessibility/overview)                         | [Custom Key Handling in Timeline](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/timeline/accessibility/custom-keyboard-navigation)                         |
| [ToggleButton](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/togglebutton/accessibility/overview)                 | [Custom Key Handling in ToggleButton](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/togglebutton/accessibility/custom-keyboard-navigation)                 |
| [ToolBar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/toolbar/accessibility/overview)                           | [Custom Key Handling in ToolBar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/toolbar/accessibility/custom-keyboard-navigation)                           |
| [TreeList](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/accessibility/overview)                    | [Custom Key Handling in TreeList](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/accessibility/custom-keyboard-navigation)                    |
| [TreeView](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/treeview/accessibility/overview)                         | [Custom Key Handling in TreeView](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/treeview/accessibility/custom-keyboard-navigation)                         |
| [Window](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/window/accessibility/overview)                                 | [Custom Key Handling in Window](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/layout/window/accessibility/custom-keyboard-navigation)                                 |
| [Wizard](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/wizard/accessibility/overview)                             | [Custom Key Handling in Wizard](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/navigation/wizard/accessibility/custom-keyboard-navigation)                             |

## Basic Usage Pattern

The example below shows the structure of a `KendoKeydown` handler. The same pattern applies to all supported wrappers.

```Razor HtmlHelper
	@(Html.Kendo().Grid()
		.Name("grid")
		.Navigatable()
		.Events(events => events.KendoKeydown("onGridKendoKeydown"))
	)
```

```javascript
	function onGridKendoKeydown(e) {
		var component = e.sender;
		var keys = kendo.keys;

		if (e.keyCode === keys.DOWN) {
			e.preventKendoKeydown = true;
		}

		if (e.keyCode === 68) {
			e.preventKendoKeydown = true;
			console.log(component.element.attr("id"), "handled a custom key.");
		}

		if (e.ctrlKey && e.keyCode === 88) {
			e.preventKendoKeydown = true;
			console.log(component.element.attr("id"), "handled Ctrl+X.");
		}
	}
```

### Blocking the Default Behavior

To prevent a wrapper from reacting to a specific key, set `e.preventKendoKeydown` to `true` for that key in the handler. You do not need to call `e.preventDefault()` in most cases because setting the flag is sufficient to stop the component from handling the key.

If you also want to prevent the browser's default behavior for that key, call `e.preventDefault()` in addition to setting the flag:

```javascript
	function onGridKendoKeydown(e) {
		if (e.ctrlKey && e.keyCode === 82) {
			e.preventDefault();
			e.preventKendoKeydown = true;
		}
	}
```

### Adding a Custom Key Combination

You can add a key combination that the wrapper does not use. You do not need to set `e.preventKendoKeydown = true` in this case because there is nothing to block. Set the flag only when you want to take over a key that the component already handles.

```javascript
	function onGridKendoKeydown(e) {
		if (e.keyCode === 73) {
			console.log("Custom shortcut activated.");
		}
	}
```

## See Also

* [Accessibility in Telerik UI for ASP.NET MVC](https://www.telerik.com/aspnet-mvc/documentation/accessibility/overview)
