# Keyboard Support

`RadGridView` exposes several useful properties and events, which can help you control the keyboard interaction and get notified when keyboard events occur. Moreover, using the keyboard you can perform some common tasks, such as:

* Change the **selection**—Use the **arrow** keys to change your selection. To select multiple rows hold the **Shift\Ctrl** key pressed and use the arrow keys or the mouse to select the desired rows.
* **Sort** by multiple columns—Hold the **Shift** key pressed and click all column headers by which you wish to sort your data.
* **Sort the current column**—Press **F3** to change the SortState property of the current column. You can also hold the **Shift** key while pressing **F3** to add, update, or remove the CurrentColumn from the sorting.
* **Filter the current column**— Press the **F5** key to open the filtering popup or the filtering button's drop-down menu depending on the `FilteringMode` property.
* **Group the current column**— Press **F7** to group/ungroup the current column.
* **Start cell edit**—Press **F2** and the current cell will enter in edit mode.
* **End cell edit**—Press **Enter** while the cell is in edit mode. This will confirm the changes you've made.
* **Cancel cell edit**—Press **Escape** while the cell is in edit mode. This will rollback the changes you've made.
* **Add new row**—Press **Insert** and new row will be inserted automatically.
* **Delete existing row**—Users can delete (if supported by the collection assigned to the ItemsSource of RadGridView) selected items using **DELETE** key. This feature can be controlled with RadGridView's `CanUserDeleteRows` property. Additional to this, the delete command won't be executed if the `IsReadOnly` property of RadGridView is **true** or the selected row is in edit mode.

> In case you require to **utilize different commands corresponding to the keyboard interaction**, you may take advantage of the IKeyboardCommandProvider interface and implement your custom logic. Please check  [this article](https://www.telerik.com/products/wpf/documentation/controls/radgridview/commands/keyboardcommandprovider) for further information.

In the following table you can find some of the actions and the respective combination that invokes them:

| Hotkey      | Command                                   | Action                                                                                     |
| ----------- | ----------------------------------------- | ------------------------------------------------------------------------------------------ |
| Enter       | RadGridViewCommands.CommitEdit            | Commit the changes(edit mode) and select next row                                          |
| Enter       | RadGridViewCommands.CommitEdit            | Select next row                                                                            |
| F2          | RadGridViewCommands.BeginEdit             | Put current cell in edit mode                                                              |
| F3          | RadGridViewCommands.SortColumn            | Change the SortingState of the CurrentColumn                                               |
| Shift + F3  | RadGridViewCommands.SortAdditionalColumn  | Add/update/remove the CurrentColumn from the sorting                                       |
| F5          | RadGridViewCommands.FilterColumn          | Open the filtering popup or the button's drop-down depending on the FilteringMode property |
| F7          | RadGridViewCommands.GroupColumn           | Group/ungroup the CurrentColumn                                                            |
| Esc         | RadGridViewCommands.CancelCellEdit        | Cancel the editing of the current cell                                                     |
| Insert      | RadGridViewCommands.BeginInsert           | Insert new row                                                                             |
| Delete      | RadGridViewCommands.Delete                | Delete selected row                                                                        |
| Left key    | RadGridViewCommands.MoveLeft              | Focus next cell on the left                                                                |
| Right Key   | RadGridViewCommands.MoveRight             | Focus next cell on the right                                                               |
| Down Key    | RadGridViewCommands.MoveDown              | Focus next cell below                                                                      |
| Up Key      | RadGridViewCommands.MoveUp                | Focus next cell above                                                                      |
| Page Up     | RadGridViewCommands.MoveTop               | Focus first cell                                                                           |
| Page Down   | RadGridViewCommands.MoveBottom            | Focuses first cell of last row                                                             |
| Home        | RadGridViewCommands.MoveHome              | Focus first cell of selected row                                                           |
| End         | RadGridViewCommands.MoveEnd               | Focus last cell of selected row                                                            |
| Tab         | RadGridViewCommands.MoveNext              | Focuses next cell                                                                          |
| Tab + Shift | RadGridViewCommands.MovePrevious          | Focuses previous cell                                                                      |
| Ctrl + C    | RadGridViewCommands.Copy                  | Copy text                                                                                  |
| Ctrl + V    | RadGridViewCommands.Paste                 | Paste text                                                                                 |
| Ctrl + F    | RadGridViewCommands.Search                | Show Search Panel                                                                          |
| Space       | RadGridViewCommands.CollapseHierarchyItem | Collapse a particular item in the hierarchy                                                |
| Space       | RadGridViewCommands.ExpandHierarchyItem   | Expand a particular item in the hierarchy                                                  |

> important The actions might vary depending on the mode of RadGridView and different property combinations.

> You can find more information regarding **RadGridView\`s commands** in the [Commands Overview](https://www.telerik.com/products/wpf/documentation/controls/radgridview/commands/overview) article.

## Properties

* Set the `IsTabStop` property to include/exclude the control in the tab navigation cycle. If this property is set to **True**, then the control will be included; if it is **False** it will be skipped.

* The `TabIndex` property defines the index of the control in the tab navigation cycle. The lower the number is, the earlier the control will be focused while navigating using the Tab key. If you set this property, do not forget to set IsTabStop to **True**.

* The `TabStopMode` property of the **column** denotes if its cells could gain focus with the TAB key navigation.

## Events

Here is a list of the common keyboard events exposed by the RadGridView, `GridViewRow` and `GridViewCell` elements:

* `KeyUp`—occurs when the user releases a keyboard key. The type of the passed event arguments is `KeyEventArgs`.

* `KeyDown`—occurs when the user presses a keyboard key. The type of the passed event arguments is `KeyEventArgs`.

In the following example, you can see how to subscribe to KeyDown and KeyUp events from XAML.

**Subscribe to KeyDown and KeyUp events**

```XAML
<telerik:RadGridView x:Name="radGridView" KeyDown="radGridView_KeyDown" KeyUp="radGridView_KeyUp"/>
```

> tip It is always a good practice to attach your event handlers in the XAML, whenever your application logic allows this.

The implementation of both event handlers is located in the code-behind file (C# or VB.NET) and looks like this:

**Implementation of KeyUp and KeyDown events**

```C#
private void radGridView_KeyDown(object sender, KeyEventArgs e)
{
    MessageBox.Show("The pressed key is: " + e.Key.ToString());
}
private void radGridView_KeyUp(object sender, KeyEventArgs e)
{
    MessageBox.Show("The released key is: " + e.Key.ToString());
}
```

```VB.NET
Private Sub radGridView_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
    MessageBox.Show("The pressed key is: " & e.Key.ToString())
End Sub

Private Sub radGridView_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs)
    MessageBox.Show("The released key is: " & e.Key.ToString())
End Sub
```

You can attach to the other keyboard events in the same way.

## See Also

* [RadGridView Overview](https://www.telerik.com/products/wpf/documentation/controls/radgridview/overview2)
* [Mouse Support](https://www.telerik.com/products/wpf/documentation/controls/radgridview/features/overview-mouse-support)
* [Keyboard Command Provider](https://www.telerik.com/products/wpf/documentation/controls/radgridview/commands/keyboardcommandprovider)
* [Configure the Data Bindings](https://www.telerik.com/products/wpf/documentation/controls/radgridview/populating-with-data/configuring-the-databindings)
* [Managing Data](https://www.telerik.com/products/wpf/documentation/controls/radgridview/features/overview-managing-data)
