Hi,
I want to use spacebar or arrows keyboard press to trigger actions.
How to with Velo or HTML iFrame ?
Thank you!
Ben
Hi,
I want to use spacebar or arrows keyboard press to trigger actions.
How to with Velo or HTML iFrame ?
Thank you!
Ben
Hi,
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: KeyboardEvent - Velo API Reference - Wix.com
You can also add custom code to any page of your site or the entire site, you can read about it here: Embedding Custom Code on Your Site | Help Center | Wix.com
Here is an example code:
<script>
document.addEventListener("keydown", event => {
if (event.isComposing || event.keyCode === 83) {
console.log("this is awesome!");
}
});
</script>
The specific keycodes can be found here: https://keycode.info/
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