Streaming live at 10am (PST)

Triggering interaction using a keyboard input

After a bit of research, I have figured out how to trigger a Webflow interaction using a key press or keyboard input.

Insert the following code before the </body> tag on your page:

<script>
      	$(document).on('keyup', function(event) {
      	if (event.which === 27) {
         	$('.CLASS-NAME').click();
       		}
        });
 </script>

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.

Nice tip @JSW.

Thank you for sharing with the community!

1 Like