Accessible Button Events

Share this video with your friends

Send Tweet

Often buttons need to be handled by JavaScript, and if done improperly it can lead to accessibility issues. In this lesson you will improve a major news organization's global header with some basic HTML and JavaScript.

Kent C. Dodds
Kent C. Dodds
~ 8 years ago

It's notable that you'll also want to check for which key triggered the keydown. Without doing this, you'll trigger your button when any key is pressed (like <kbd>a</kbd>). I've updated the example to demonstrate this: jsbin.com/ramoy/edit. Thanks for the lesson Marcy!