Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling a hard key (ENTER) to emulate a button click using JavaScript [duplicate]

Tags:

javascript

We have an HTML app that collects transaction data (picks, putaways, replenship, etc.) in a distribution center. We'd like to use an Intermec CK71 with WinMobile 6.5 and a browser as the data collection device. At present our users scan / key into data entry fields and then click the NEXT button to enter data on the server.

Is there a way to use JavaScript to enable a hard key (ENTER) to emulate the cursor tap on the NEXT button? We can get the CK71's scan code for the ENTER key by using Intermec's on board key board remapping utility.

Any help would be greatly appreciated.

Thanks

like image 691
WiFiGuy Avatar asked Mar 29 '13 15:03

WiFiGuy


1 Answers

Make the "Next" button a button of type="submit" so that the onsubmit on the form triggers.

Pressing enter is then the same as 'clicking' the button, it will also cause the onsubmit to fire.

This also requires you to have a <form> surrounding the button. You can have buttons without a form I would argue that is bad design.

If this solution works for you rejoice because you don't need to get into any JavaScript nastiness.

like image 181
Halcyon Avatar answered Nov 01 '22 10:11

Halcyon