601
Views
10
Comments
Solved
I want to trigger an action with the "enter" key
Question
Service Studio Version
11.54.20 (Build 62656)


I'm making a query site, it has an input field and next to it a "consult" button. I want the button to be pressed through the "enter" key.

I already put the (Is form Default) to "yes" but it doesn't work.

UserImage.jpg
vikas sharma
Champion
Solution

Hi Vinicius,

default button click trigger on enter key only when the input field and button are inside the form only. So could you please confirm both input field and button are inside form. If not please try to put them inside form then make the button default Yes, it should work.

regards

2023-08-29 14-56-14
vn_perpetuo

It works, thanks! 

I had put the input and buttons inside a container, so it wasn't working. but after putting both inside a form, it worked perfectly.

2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi Vinicius,

Hope to find you well. 

The action that your default button is running is refreshing the query? Does the button works correctly if you press it with mouse click?

Can you share some prints of the correspondent code to verify if something is missing?


Hope this can help.


Best regards,

Ricardo

2023-08-29 14-56-14
vn_perpetuo

Hi Ricardo, thanks for your attention.

I'll send some pictures, hope it helps.

SCC2.png
SCC1.png
2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi,

Thanks! Can you please share prints from the "ConsultarOnClick" action? Maybe something there isn't working. Is any kind of warning associated with the button? I saw an orange square around it in one of the prints (maybe the warning that the default is only valid for buttons inside forms).

Can you please validate if the functionality works with the mouse click?

Maybe you can check here a solution to your problem:

https://www.outsystems.com/forums/discussion/56620/is-default-button-on-reactive-web/

It's a similar case.


Thank you!


Best regards,

Ricardo

2023-08-29 14-56-14
vn_perpetuo


Hello Ricardo, an unforeseen situation has arisen and I will have to make a trip now, unfortunately I will not be able to check it now, but tomorrow as soon as I arrive I will see the details you sent and I will give you the answer here. Thank you very much for your attention.

2023-08-29 14-56-14
vn_perpetuo
consultar2.png
consultar1.png
2024-09-17 08-54-53
Jerome Rajadurai J

Hi @Vinicius Perpetuo , Try hitting the Client action through a JS Script that is triggered while Enter Key got a hit.


eg:

 

 const handleKeyPress = (event) => {

      if (event.key === 'Enter' || event.keyCode === 13) {

        // Perform your desired action here

        $actions.ConsultarButtonOnClick(); ---> Client Action

      }

    };

    document.addEventListener('keydown', handleKeyPress);


    return () => {

      document.removeEventListener('keydown', handleKeyPress);

    };

2023-08-29 14-56-14
vn_perpetuo

Hello Jerome, an unforeseen situation has arisen and I will have to make a trip now, unfortunately I will not be able to check it now, but tomorrow as soon as I arrive I will see the details you sent and I will give you the answer here. Thank you very much for your attention.

UserImage.jpg
vikas sharma
Champion
Solution

Hi Vinicius,

default button click trigger on enter key only when the input field and button are inside the form only. So could you please confirm both input field and button are inside form. If not please try to put them inside form then make the button default Yes, it should work.

regards

2023-08-29 14-56-14
vn_perpetuo

It works, thanks! 

I had put the input and buttons inside a container, so it wasn't working. but after putting both inside a form, it worked perfectly.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.