Revolutionize Your Application with Enhanced Keyboard Accessibility

Admir Mehanovic, CEO @

Admir Mehanovic

CEO @ Penzle
a person using a laptop

Keyboard support is one of the most important accessibility parts that every application should include. We must ensure every user interaction including people with disabilities. It is important that every part of our application can be used through the keyboard as well.
In previous blog articles, we got acquainted with accessibility standards and how to design and develop with accessibility in mind. In my last blog article in the series of digital accessibility, I wanted to discuss keyboard support for our application.

Types of Disabilities

Our application should be operable by keyboard users. Who are keyboard users?

  • Persons with physical disabilities who have limitations in the use of their arms. They use a specially designed keyboard, but can't use a mouse. They don't use any other assistive technology and can't use a website if they need a mouse.
  • Persons who are legally blind. They use a screen reader to browse a website. It's a text to speech program that reads out the content of the website. They operate websites using the keyboard alone as they can't see the screen and use a mouse.
  • Persons who use a mouse with lowered hand dexterity. They find it difficult to click on small items or may accidentally click the wrong item if buttons are put too close together. They struggle with the use of mouse and keyboard more.
  • Persons with situation disabilities. In cases of e.g. arm injury,  you may use the keyboard more than usual, or you are trying to shop online while eating. There are a lot of reasons people do not use a keyboard.

Keyboard Commands

When you operate a website with a keyword, there are just a few basic commands that you need to know. There are various elements on the page that could be operated like input controls, links. These are called focusable elements. Pressing TAB on the keyboard moves the keyboard focus to the next focus element, pressing SHIFT + TAB moves backwards. Pressing the TAB through the IM site, you can see the slight outline showing the time moving. To move back press SHIFT and TAB. To navigate to the link in the menu item, press ENTER. It will activate a link or submit a form.

Keyboard command Description
TAB Move between focusable elements
SHIFT+TAB Back to previous focusable element
ENTER Submit a form or active link
SPACE Toggle a checkbox or open a select control.
ARROW KEY Scroll up and down on the page

Keyboard Focus Visibility

When tabbing through different elements of the page with keyboard focus, a color outline is needed. Without the outline the user will not see what the element is focused on and it will be impossible to browse a site. It’s like using a mouse without seeing the cursor.

Focus should be improved using a focus selector.

    // styles here

The default focus works well in most cases. The only occasion where you could change it is if you have a background or color that is a similar shade of color and the outline is not clear. There are a few techniques how you can improve focus indicators:

  1. Change the color of the outline
    .form .btn{
        outline-width: 1px;
        outline-style: solid;
  2. Change the color of the entire element
    .form .btn{
        color: #000;
  3. Style of hyperlinks can be improved. Default outline around links can look a bit clunky.
        text-decoration: underline;

Using focus within you can make the form itself stand out visually in addition to style applied to the individual focused input. This can help the perceptibility of focus overall.

    border: 1px solid blue;

Keyboard Focus Order

WCAG 2.3.4 Focus order-level A criteria – Focus elements must receive focus in an order that preserves meaning and operability. Focus of the element should flow in a way that users expect. We should avoid jumping between sections.

Graphical interface keyboard focus order.

For example, users expect to read the page from left to right end from top to bottom. Users will expect the first focus element to be the logo then the navigation menu.

Using tabindext attribute you can control keyboard focus.

<button tabindex="3">Search</button>

Tab index can have 3 values:

  • -1 – Element is not in the tab order.
  • 0 – You can tab to an element but the focus order is determined by the order of the HTML.
  • 1+ - Any positive number indicates that you can tab to an element and the focus order is determined by the value of the attribute. Can be between 1 and 32.767.

Accessible Forms

Every application consists of different forms where we request an engagement. Forms should be clear, logical and easy to use.

Labelling a Form

Screen readers have forms mode where there is read out text directly associated with an input element. It’s important to name those properties in a proper way.

With each input element, we need to associate the corresponding name. The best way is to use label elements along with the input field. Labels are preferred because they solve two problems at once, the name of the element rendered visually and the name of the element in the accessibility tree. If we use labels and input elements those elements need to be connected.

<input type="password">

This example doesn’t connect those elements. There are two ways to solve this problem:

  1. Wrap the input inside the label.
        <input type="password">
  2. Set input ID and use for attribute in the label.
    <label for="password">Password</label>
    <input type="password" id="password">

Another great usability improvement with this approach is if you can click to label in order to select a field.

ARIA Labelling

Sometimes there is a need for an input field without a form label. One of the most common scenarios is search input inside the navigation header. Adding aria-label attribute screen readers will read out while this attribute will not be visible.

<input type="search" aria-label="Search" id="search">

If there is an input field along with the button you can associate input with button text in the following way:

<input type="search" aria-describedby="btn-search" id="search">
<button id="btn-search">Search</button>

Additional Description

Screen readers only see the labels and if you need to provide additional text or description for the input element you need to add an additional aria attribute.

<label for="password">Password</label>
<input type="password" id="password" aria-describedby="password-rule">
<span id="password-rule">Must be at least 3 characters long</span>

Now the screen reader will read the label and additional description described by the associated element.

Disabled vs Read-only Fields

When you use disabled or read-only field you have to use the correct method to meet WCAG. Adding disabled or read-only attributes makes a special type of field which doesn’t take a value. Difference between disable and read-only field:

Disabled Read-only
Greyed-out appearance Greyed-out appearance
Can't click into field Can't click into field
Can't edit the value Can't edit the value
Value not submitted to server Value is submitted to server
Don't receive keyboard focus Receive keyboard focus

Field Types

HTML 5 introduced a lot of new types of form input such as search, email, date etc. They can help in adding context for users and improve the experience. A different keyboard will be displayed on mobile when entering a telephone number versus an email.

Form Validation

You should always state which fields are optional and which are required. It could be a very bad experience if the user has to guess validation and after submitting the form to come back and re-enter data. Using an asterisk, the user sees which fields are required. Screen readers don’t recognize asterisk as a required field and a note in the HTML needs to be added.

Adding required attributes would cause the screen reader to announce it as a required field. Another good advantage is that browsers will pick up attributes and add validation with a little popup message.

<input type="text" required>

If you don’t want to have browser validation which can be in conflict with your javascript validation, use the aria required attribute instead.

<input type="text" aria-required="true">

Now screen readers will read that out as required field:

Validation Messages

Adding aria-invalid to the field using javascript after failing validation will tell screen readers that there is a problem with the field.
If you hit the submit button or populate the input field with wrong data additional validation messages will appear.

<input type="password" id="password" aria-required="true">
<span>This filed is required.</span>

The main problem is that screen readers are not informed of this validation message since this validation is not linked to the field in any way.
Adding the aria-invalid attribute will inform the screen reader that the field is not valid. Using aria-describedby will read out associate error messages so that the user knows what the issue is.

<input type="password" aria-required="true" aria-invalid="true" aria-describedby="password-rule"><span id="password-rule">This filed is required.</span>

Validation Summary

Adding a validation summary on the top of the form makes it much clearer when errors occur and guide the user towards those errors. When the user hits the submit button and if issues are found, the script will set keyboard focus to the validation summary. This jumps the user right back to the start of the form to explain there is a problem.


Status messages must be identified programmatically so that assistive technologies can announce them. This rule is according to WCAG 4.1.3 Status Messages – Level AA criteria.
There are two ways that you can announce a status message.

  1. Set keyboard focus to the validation summary. Keyboard focus will bring screen user attention to the issues.
  2. Use live region recommended in WCAG 4.1 which uses aria attribute to mark validation summary live region. Live region announces messages to the user even if they don’t receive keyboard focus. Adding the role attribute of alert informs the screen reader that they need to pay attention to this element because all changes need to be announced to the user.
    <div id="validation-summary"></div>
    <div id="validation-summary" role="alert"></div>

    This informs screen readers that they need to pay attention to this element because all changes need to be announced.


In this blog article, we have seen how we can make our application keyboard accessible. How to design and validate form when users interact with it. A form is a complex element that manages a lot of information and we have to make sure that everything is clear and understandable for all users.

Following this guide makes your application supported by keyboard and accessible for screen readers and ensures that users with or without a disability have a good user experience.

Cookie Consent

This website uses cookies to improve your experience while navigating through the website. You can choose to accept or decline to have your browsing tracked by cookies while you’re using this site.