The ensure all elements are clickable using the Enter key, I'm using the following method:
document.addEventListener('keydown', function(e){
if( e.keyCode === 13 ) {
e.target.click();
}
});
And for most clicks, it works really well. The problem is with elements that don't have a click event bound directly, but are clickable through bubbling up. For example:
jQuery(document).on('click', function(e){
jQuery(e.target).addClass('active');
});
Clickable elements that are bound this way, will not be triggered using the first example. I've found out that NVDA, somehow, literally makes all elements clickable using the keyboard, whatever the method used to bind them. If NVDA is turned on, elements that are bound just like in example number 2 will be triggered.
I'd like to understand how NVDA does this (or if you have another idea to approach this) so I can copy that behavior to my application, that is being used by people with motor impairments and have to use the keyboard solely, without screen readers.
The solution has to be pure JS or jQuery.