You should replace ‘class name’ with the class of the element that would normally activate the trigger. Something like ‘popup-close’.
You should also replace ‘27’ with the number that represents the key you want to trigger the interaction. Find the key here.
Please note that this will only trigger ‘click’ interactions. It works by simulating a users click on an element, rather than directly triggering the interaction itself.
I want to continue this old conversation because I had to go through a million threads to find this ONE simple solution to my focus issue … I have a trigger that opens a form when an H2 title is pressed. This works flawlessly with the trigger interactions in webflow but for Accessibility click through NOTHING worked. Aria labels - random other things I found in so many forum spaces. This solution needs to be highlighted and the problem that webflow has with ease of adding accessibility is honestly shameful for a company that has been in business since 2013 – it’s 2020 … and we are having to spend DAYS researching solutions for accessibility on this otherwise awesome tool! Ya’ll should kind of be ashamed of yourselves… and thanks @JSW for saving my ever loving life today with this fix!!!
Does anyone know how to make this work for more than one instance on a page? As in, how can I set it up so that all my click-driven interactions will be triggered with this code? As of now, I got it to work but only once. It won’t apply to multiple classes.
Since most browsers have deprecated event.which use event.key instead. The same link shows .key values as well.
It should look something like this (event.key === 'Escape')
Also note your elements class needs to be in all lowercase.
Thanks for sharing, this was super helpful and worked like a charm once updated!