ToolBar - Keyboard Support

  • Spellcheck
  • Language
    • English
    • German
    • French
  • Align
    • Right
    • Left
    • Center
  • Bold
  • Italic
  • Underline
  • Color
    • Red
    • Blue
    • Green
  • Border
    • None
    • Light
    • Strong

Demo Configurator

  • Command keyAlt
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

Keyboard Support

A critical requirement for software accessibility is keyboard support as a complete alternative to pointing devices (mouse, etc.).

Keyboard support is comprised of command key, focus key, and keyboard navigation. RadToolBar will seamlessly switch between mouse and keyboard navigation.

In order to configure keyboard support with RadToolBar its KeyboardNaviagationSettings should be set:

<telerik:RadToolBar ID="RadToolBar1" runat="server" >
    <KeyboardNavigationSettings CommandKey="Alt" FocusKey="M" />
</telerik:RadToolBar>
    

The KeyboardNavigationSettings exposes two properties to configure the keyboard combination that sets focus to the control:

  • FocusKey: An upper-case letter or number.
  • CommandKey Ctrl , Alt, Shift, or any combination of two of these keys.

When there are multiple ToolBars on a given page, each of them may have a different activation combination.

In this particular example, the [CommandKey] and the [FocusKey] can be customized in the Demo Configurator.

Once the RadToolBar has been focused (by pressing [CommandKey] + [FocusKey]):

  • To navigate among RadToolBar items use Left and Right arrows.
  • To perform a click on the active item press Enter.
  • То еxpand contents of an item (for example its drop-down) press Space or use the Down arrow.
  • To collapse an expanded drop-down press Esc, while drop-down item is active.
  • To navigate among the drop-down items use Down and Up arrows.
  • To select the current drop-down item press Enter.

Note: It is recommended to avoid [CommandKey] + [FocusKey] combinations matching keyboard shortcuts used in browsers. If the combination coincides with an existing browser shortcut the control may be unable to focus.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs"Inherits="ToolBar.Examples.Functionality.KeyboardSupport.DefaultCS" Language="c#"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-narrow">
        <telerik:RadToolBar RenderMode="Lightweight" ID="RadToolBar1" runat="server" EnableShadows="true">
            <Items>
                <telerik:RadToolBarButton Text="Spellcheck" CheckOnClick="true" Group="Spellcheck" AllowSelfUnCheck="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarSplitButton Text="Language" EnableDefaultButton="false">
                    <Buttons>
                        <telerik:RadToolBarButton Text="English" CheckOnClick="true" Group="Language">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="German" CheckOnClick="true" Group="Language">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="French" CheckOnClick="true" Group="Language">
                        </telerik:RadToolBarButton>
                    </Buttons>
                </telerik:RadToolBarSplitButton>
                <telerik:RadToolBarDropDown Text="Align">
                    <Buttons>
                        <telerik:RadToolBarButton Text="Right" CheckOnClick="true" Group="Align">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Left" CheckOnClick="true" Group="Align">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Center" CheckOnClick="true" Group="Align">
                        </telerik:RadToolBarButton>
                    </Buttons>
                </telerik:RadToolBarDropDown>
                <telerik:RadToolBarButton Text="Bold" CheckOnClick="true" Group="Bold" AllowSelfUnCheck="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text="Italic" CheckOnClick="true" Group="Italic" AllowSelfUnCheck="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text="Underline" CheckOnClick="true" Group="Underline" AllowSelfUnCheck="true">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarSplitButton Text="Color" EnableDefaultButton="false">
                    <Buttons>
                        <telerik:RadToolBarButton Text="Red" CheckOnClick="true" Group="Color">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Blue" CheckOnClick="true" Group="Color">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Green" CheckOnClick="true" Group="Color">
                        </telerik:RadToolBarButton>
                    </Buttons>
                </telerik:RadToolBarSplitButton>
                <telerik:RadToolBarDropDown Text="Border">
                    <Buttons>
                        <telerik:RadToolBarButton Text="None" CheckOnClick="true" Group="Border">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Light" CheckOnClick="true" Group="Border">
                        </telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Strong" CheckOnClick="true" Group="Border">
                        </telerik:RadToolBarButton>
                    </Buttons>
                </telerik:RadToolBarDropDown>
            </Items>
        </telerik:RadToolBar>
    </div>


    <telerik:RadAjaxManager ID="radajaxmanager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="configurationpanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="configurationpanel1" LoadingPanelID="radajaxloadingpanel1" />
                    <telerik:AjaxUpdatedControl ControlID="radtoolbar1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel runat="server" ID="radajaxloadingpanel1" />

    <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1">
        <Views>
            <qsf:View>
                <qsf:ConfiguratorColumn ID="ConfiguratorColumn1" runat="server" Size="Wide">

                    <ul class="fb-group">
                        <li>
                            <qsf:DropDownList runat="server" ID="DropDownListCommandKey"
                                AutoPostBack="true"
                                Width="160px"
                                Label="Command key" />
                        </li>
                        <li>
                            <qsf:MaskedTextBox runat="server" ID="RadMaskedTextBoxFocusKey"
                                ValidationGroup="FocusKeyValidator"
                                CausesValidation="true"
                                AutoPostBack="true"
                                Width="160px"
                                LabelWidth="80"
                                Mask="L"
                                Text="M"
                                SelectionOnFocus="SelectAll"
                                Label="Focus key" />
                        </li>
                        <li>
                            <asp:CustomValidator ID="CustomValidator1" runat="server"
                                Display="Dynamic"
                                ValidationGroup="FocusKeyValidator"
                                ForeColor="Red"
                                Text="* Please type a valid uppercase Latin letter"
                                ClientValidationFunction="validateFocusKey" />
                        </li>
                    </ul>
                </qsf:ConfiguratorColumn>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    <telerik:RadScriptBlock runat="server">
        <script>
            function validateFocusKey(source, arguments) {
                var maskedTextBox = $find("<%= RadMaskedTextBoxFocusKey.ClientID %>");
                var textBoxValue = maskedTextBox.get_textBoxValue().trim();

                if (textBoxValue.length != 1) {
                    arguments.IsValid = false;
                    return;
                }

                var keyCode = textBoxValue.charCodeAt(0);

                if (keyCode < 65 || keyCode > 90) {
                    arguments.IsValid = false;
                    return;
                }
                arguments.IsValid = true;
            }
        </script>
    </telerik:RadScriptBlock>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?