Accessibility in Angular–Good Practices and Pitfalls

Accessibility in Angular–Good Practices and Pitfalls

In today’s article, we will focus on reacting to users via keyboard events or shortcuts. We will take five real-life examples of handling keyboard listeners in an Angular app.

_“The web is used by a wide variety of people, including those who have visual or motor impairments. A variety of assistive technologies are available that make it much easier for these groups to interact with web-based software applications. In addition, designing an application to be more accessible generally improves the user experience for all users.” — [Angular’s Accessibility Guide_](https://angular.io/guide/accessibility)

In today’s article, we will focus on reacting to users via keyboard events or shortcuts. We will take five real-life examples of handling keyboard listeners in an Angular app.

Let’s get started.

Case Study 1

Let’s say you have an input field in your component and you want to open a dialog when the user presses F2. You can do it in two ways.

Option 1

Add (keydown.F2) in your HTML:

<input matInput (keydown.F2)=”onF2KeyPress($event)”>

And the onF2KeyPress() method in your TypeScript code:

onF2KeyPress(event: KeyboardEvent) {
    this.openOptionsDialog(…);
}

accessibility javascript angular programming web-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Wondering how to upgrade your skills in the pandemic? Here's a simple way you can do it.

Corona Virus Pandemic has brought the world to a standstill. Countries are on a major lockdown. Schools, colleges, theatres, gym, clubs, and all other public

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

Important Reasons to Hire a Professional Web Development Company

    You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...

How to become a Web Developer | Web Development Career in 2020

How to Become a Web Developer will provide you with detailed roadmap to begin your career as a Web Developer in 2020.