Make elements with tabIndex accessible via keyword
This commit is contained in:
parent
3dd5dba9e3
commit
93f98752c0
2
js/application.min.js
vendored
2
js/application.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1278,6 +1278,30 @@ _$$('.contact-form').forEach(element => {
|
||||
);
|
||||
});
|
||||
|
||||
// =============================================================================
|
||||
// KEYBOARD INPUT
|
||||
// =============================================================================
|
||||
|
||||
/*
|
||||
* Make elements with tabIndex 0 accessible with keyboard.
|
||||
*/
|
||||
|
||||
fcn_theBody.querySelectorAll('[tabindex="0"]:not(a, input, button, select)').forEach(element => {
|
||||
element.addEventListener(
|
||||
'keydown',
|
||||
e => {
|
||||
// Only for actions on focused element
|
||||
if (e.currentTarget != document.activeElement) return;
|
||||
|
||||
// When pressing space or enter
|
||||
if (e.keyCode == 32 || e.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
e.currentTarget.click();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// =============================================================================
|
||||
// KEYWORD INPUTS
|
||||
// =============================================================================
|
||||
|
Loading…
x
Reference in New Issue
Block a user