How can I check a checkbox with the keyboard only?

Dear all,

I am using checkbox for creating a custom form on my website. To make it accessible, I would like the users not to be forced to click on the box with the mouse. I would like to create a keybord shorcut. But, checkbox doesn’t have onKeyPress event function. Can you help me to do that ?
Thank you so much.

Best regards.

You could use a Custom Element to intercept key presses but the element would need to be in focus (ie. clicked on once) to receive the keypresses.

Then you could pass them to/from Velo by firing events and intercepting them with on() and from there do the checkbox logic.

I realize though that this isn’t ideal and will report internally that checkboxes aren’t selectable via tab/space on a keyboard.

As for the feature request to globally capture keypresses on a page you can request this feature on the product roadmap: Product Roadmap