Keyboard Interaction

With the keyboard navigation enabled in the NumericTextBox control, it is possible to control the actions with the provided shortcut keys. Almost all the NumericTextBox functionality that are done through mouse can be controlled with shortcut keys.

The various keyboard shortcuts available within the NumericTextBox control are discussed in the following table.

Keyboard Shortcuts

Shortcut Key Description

Access key

+ j
Focuses the control
Up Increments the value
Down Decrements the value
Tab Focus the next element

Configuring Keyboard Navigation

The following steps explain the implementation of keyboard interaction in NumericTextBox.

In the View page add the below code. Set the access key property to the NumericTextBox for focusing the control while key is pressed. We need to use ‘HtmlAttributes’ property to add the ”access key” attribute to the Editor elements. ‘HtmlAttributes’ property is used to add HTML attributes like, id, class etc.. to the components. We need to use IDictionary<string,object> to specify the HTML attributes.

  • cshtml
  • @{IDictionary<string, object> numericAttribute = new Dictionary<string, object>();
    
      numericAttribute.Add("accesskey", "j");
    
    }
    
    <ej-numeric-text-box id="numeric" name="Numeric" value="11" html-attributes="numericAttribute"/>

    Run the above example and press Access key + j key to focus the NumericTextBox widget. Perform provided functionality by using keyboard shortcuts.