Using a hotkey to submit an HTML form?

I have a very simple HTML form containing only a submit button and a text box. Is there an easy way to use a hotkey to submit this form as an alternative to clicking a button?

Thanks in advance: -)

+5
source share
3 answers

Submit buttons may have accesskeys , but there are disadvantages . For users, it would probably be better to just press the tab key to focus the submit button, and then press enter.

+2
source

"keyDown", "keyPress", JS- (JQUERY MOOTOOLS).. Ctrl + S .

JQuery . http://api.jquery.com/keypress/

Mootools . http://mootorial.com/wiki/mootorial/03-native/05-event

+1

jQuery ( )... , "YourID" "document" ( , . , keypress , , , .

$("#YourID").keypress(function (e) {
   var code = (e.keyCode ? e.keyCode : e.which); // grabs keycode pressed
   if (code == 13) {  // Code 13 is enter
        searchUPC();
   }
});
+1

All Articles