Skip to content

A lightweight library that applies a class to an element only when it is focused by tabbing.

License

Notifications You must be signed in to change notification settings

MaxMaeder/keyboardFocus.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

keyboardFocus.js

A lightweight library that applies a class to an element only when it is focused by tabbing.

Try the demo

Use cases

Perfect for showing users who use keyboard navigation what element they've focused, while not altering the experience for other users.

Usage

1. Add the script to your page

      ...
    <script src="/keyboardFocus.js"></script>
  </body>
</html>

2. Update your CSS

Create a css rule-set with the .keyboardFocus selector and whatever styles you want to be applied to an element when it is focused by tabbing.

.keyboardFocus {
  outline: 1px solid black;
}

3. Sit back, you're done!

About

A lightweight library that applies a class to an element only when it is focused by tabbing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published