New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Cancel Enter and Arrow Key Press
Updated on Oct 7, 2026
Canceling keyboard key presses
When keyboard navigation is enabled, you can cancel selected key presses. For example, cancel the Enter key to prevent edit mode or allow only one-way movement with the arrow keys.
Follow these steps to cancel a key press:
-
Enable keyboard navigation.
-
Specify a client-side function to call when a key is pressed.
-
In the client-side function, check the key code.
-
Cancel the key press when the condition is met.
This approach is demonstrated in the code samples below:
ASP.NET
<ClientSettings AllowKeyboardNavigation="true" ClientEvents-OnKeyPress="KeyPressed">
<Selecting AllowRowSelect="true" />
</ClientSettings>
And the JavaScript code:
JavaScript
function KeyPressed(sender, eventArgs) {
if (eventArgs.get_keyCode() == 13) {
eventArgs.set_cancel(true)
}
}