Community X.

Connect with other creators, share ideas, give feedback and get the latest product updates.

Jan 25

How to detect a keystroke on the keyboard. ?


I want to use spacebar or arrows keyboard press to trigger actions.

How to with Velo or HTML iFrame ?

Thank you!


2 answers0 replies


Great question!

You can trigger functions and events on keypress using Velo or writing your own custom code.

In Velo, you can trigger an event using the KeyboardEvent, there is more info about it here:$w/keyboardevent

You can also add custom code to any page of your site or the entire site, you can read about it here:

Here is an example code:

document.addEventListener("keydown", event => {
  if (event.isComposing || event.keyCode === 83) {
    console.log("this is awesome!");

The specific keycodes can be found here:

We don't recommend using this method as we can't troubleshot issue with third party code.


Hi Sebi, Thank you for your answer.

$w/keyboardevent works exclusively while the cursor is inside an "input" element, so limits a lot its use.

This will not work, for example, to simply trigger an action on an element with spacebar or arrows press.

As custom code is not recommended (and I'm not an experimented programmer;), that means there is no way to do this in Editor x (and Wix) today.

This represents, it seems to me, a great lack in optimizing the interactivity and responsiveness of a (basic) website.

Is this function part of your short-term development projects?

Thanks very much for your interest. Ben

Editor X

Design your boldest creations.