How to call function if Enter key is pressed from Touch or mobile device

Yuri Boyz
Yuri Boyz used Ask the Experts™
on
I have a responsive menu.  I call a Javascript function if enter key is pressed from mobile.
On desktop the following code works fine but how to call the function if enter key is pressed from touch devices?
jQuery("#input").keypress(function(e) {
    if(e.which == 13) {
   
     RunFunction();
    
    }
});

Open in new window

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Solutions Architect
Commented:
Try keyup:

jQuery('#input').on('keyup', function (e) {
    if (e.which == 13) {
     RunFunction();
   }
});

Open in new window

Yuri BoyzSoftware Engineer

Author

Commented:
Thanks
Can I also use keypress event?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial