# jetpack/16.3-a.5/_inc/accessible-focus.js

Jetpack – WP Security, Backup, Speed, &amp; Growth, version 16.3-a.5. 20 lines.

- Page: https://pluginprobe.com/plugins/jetpack/16.3-a.5/code/_inc/accessible-focus.js
- Raw: https://pluginprobe.com/plugins/jetpack/16.3-a.5/raw/_inc/accessible-focus.js
- Modified: 2020-07-28T17:06:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetpack/16.3-a.5/code/_inc/accessible-focus.js#L10-L20`.

```javascript
var keyboardNavigation = false,
	keyboardNavigationKeycodes = [ 9, 32, 37, 38, 39, 40 ]; // keyCodes for tab, space, left, up, right, down respectively

document.addEventListener( 'keydown', function ( event ) {
	if ( keyboardNavigation ) {
		return;
	}
	if ( keyboardNavigationKeycodes.indexOf( event.keyCode ) !== -1 ) {
		keyboardNavigation = true;
		document.documentElement.classList.add( 'accessible-focus' );
	}
} );
document.addEventListener( 'mouseup', function () {
	if ( ! keyboardNavigation ) {
		return;
	}
	keyboardNavigation = false;
	document.documentElement.classList.remove( 'accessible-focus' );
} );

```
