Use enter key in input field and a button

I can use the enter key in the input field to do something. No problem with that. But, in addition I have a Button as an alternative way to confirm the input as well. There I have an OnClick Event Logic which I would like to use if I press Enter in the Input Field.

How can I achieve that without replicating the logic?

Hello @Jorg_Beyer

You can put your logic into a custom function and use this function anywhere. Is it ok?

Regards

Hello @viktor.liablin,

that was my first reaction as well, but my gut tells me otherwise. That is why I asked first.
But now I do it as a custom function.

Thank you.

@Jorg_Beyer

If it is not ok you can use form behavior.
Use “Form” component and delete all components except input and submit button.
And add logic to “form” “On Submit Event” handler.

Regards

Good idea. I give it a try.

What would such a function look like?

@Alex_Klein sorry for the late reply, I have overseen your question. I do not understand your question.
My workaround was the replication of the logic as the logic was not very heavy but very stable. So, I gave it no second thought anymore.

1 Like

For this specific case, it could look in next way:

image

1 Like