Pressing enter on focused button should trigger clickevent

Hi,

I would like to have the same behaviour as in web applications where you can press enter on a focused button and it triggers the same action as on click. Is this already possible? I tried a few things already to work around this but I’d prefer to use RegisterCallback and not .clicked() because I often need the event information.

Thanks
Chloë

You should assign the same call back to a “KeyUpEvent” or “KeyDownEvent” and check it’ the enter key
In webdev it’s the same thing listeners are added to “click”, and “keydown”/“keyup” events

Hi @imblue4d ,

Thanks for the reply. However in frameworks like React, I think this is done by the framework? It is quite cumbersome to have to add this twice to every button.

NP,
Well react and a big chunk of the web ecosystem are open source and supported by a huge amount of companies, and community memebers
UI Toolkit is comparable to vanilla webdev in general (which is still an improvement from UGUI in my opinion)

if you want a custom solution, @Singtaa has developed an asset that interfaces jsx Preact with UI Toolkit, it’s “OneJS” on the asset store i think