From 2e38089db547f814845702fd6dad7a01972542b2 Mon Sep 17 00:00:00 2001 From: Mu-An Chiou Date: Wed, 23 Oct 2019 17:42:30 -0400 Subject: [PATCH 1/3] Trigger click on anything that are not form fields --- src/utils.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/utils.js b/src/utils.js index 97f3036..fa31a73 100644 --- a/src/utils.js +++ b/src/utils.js @@ -15,25 +15,10 @@ export function isFormField(element: Node): boolean { ) } -function isActivableFormField(element: Node): boolean { - if (!(element instanceof HTMLElement)) { - return false - } - - const name = element.nodeName.toLowerCase() - const type = (element.getAttribute('type') || '').toLowerCase() - return name === 'input' && (type === 'checkbox' || type === 'radio') -} - export function fireDeterminedAction(el: HTMLElement): void { if (isFormField(el)) { el.focus() - } else if ( - (el instanceof HTMLAnchorElement && el.href) || - el.tagName === 'BUTTON' || - el.tagName === 'SUMMARY' || - isActivableFormField(el) - ) { + } else { el.click() } } From 2918e049e0c5cd3015a5a4bf314ce5fb80917858 Mon Sep 17 00:00:00 2001 From: Mu-An Chiou Date: Wed, 23 Oct 2019 17:55:29 -0400 Subject: [PATCH 2/3] Add another note on interactive content now that we don't restrict it anymore --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fc687bb..05096d6 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ wait for either `g c` or `g i`. ## Accessibility considerations +### Character Key Shortcuts + Please note that adding this functionality to your site can be a drawback for certain users. Providing a way in your system to disable hotkeys or remap them makes sure that those users can still use your site (given that it's @@ -37,6 +39,10 @@ accessible to those users). See ["Understanding Success Criterion 2.1.4: Character Key Shortcuts"](https://www.w3.org/WAI/WCAG21/Understanding/character-key-shortcuts.html) for further reading on this topic. +### Interactive Elements + +Wherever possible, hotkeys should be add to [interactive and focusable elements](https://html.spec.whatwg.org/#interactive-content). If a static element must be used, please follow the guideline in ["Adding keyboard-accessible actions to static HTML elements"](https://www.w3.org/WAI/WCAG21/Techniques/client-side-script/SCR29.html). + ## Installation ``` From 2084ecd35bdeef9d6c9538fa9e4fb326c0bb1e67 Mon Sep 17 00:00:00 2001 From: Mu-An Chiou Date: Thu, 24 Oct 2019 14:08:28 -0400 Subject: [PATCH 3/3] Remove mentions of specific tags --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05096d6..0394cd6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Trigger an action on a target element when a key or sequence of keys is pressed on the keyboard. This triggers a focus event on form fields, or a click event on -``, `