Javascript enter key pressed event alternative for mobile site Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Javascript enter key pressed event alternative for mobile site without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have a quickfeedback widget in my site which has only one textbox. When user presses enter key, the feedback is automatically sent using ajax. But this doesn’t work in mobile devices like android, j2me and so on. Is there any alternative that works in both desktop and mobile? Adding a submit button is not acceptable for me.

Answer

I just checked on android, when you type something and press “Go” (enter alternative?) it will trigger an event and the key code is actually 13 so the same as Enter on desktop keyboards.

Edit:

I’d suggest debugging the code and checking whether the submit is actually triggered but maybe the key code isn’t always 13? Just guessing..

Edit2:

Test this code on your mobile. When I press “Go” the input value changes to “sent!” which proves that it works.

We are here to answer your question about Javascript enter key pressed event alternative for mobile site - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji