Best cross-browser method to capture CTRL S with JQuery

0 votes
My users would like to be able to hit Ctrl+S to save a form. Is there a good cross-browser way of capturing the Ctrl+S key combination and submit my form?

App is built on Drupal, so jQuery is available.
May 27 in JQuery by Edureka
• 13,640 points
94 views

1 answer to this question.

0 votes
$(window).keypress(function(event) {
     if (!(event.which == 115 && event.ctrlKey) && !(event.which == 19)) return true;
     alert("Ctrl-S pressed");
     event.preventDefault();
     return false;
 });

Keycodes can vary from browser to browser, so you may need to look for more than  115.

answered May 30 by gaurav
• 17,760 points

Related Questions In JQuery

0 votes
1 answer

How to reset a form using jQuery with .reset() method

<input type="reset"> Syntax for reset(): formObject.reset() Syntax to convert ...READ MORE

answered Jun 16 in JQuery by rajatha
• 7,040 points
103 views
0 votes
1 answer

How to convert form data to JavaScript object with jQuery?

Hello @kartik, You can use: function form_to_json (selector) { ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
1,580 views
0 votes
1 answer

How to pass parameters in GET requests with jQuery?

Hello, Here is the syntax using jQuery $.get $.get(url, data, ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
25,628 views
0 votes
1 answer
0 votes
1 answer

Using setTimeout to delay timing of jQuery actions

The JavaScript setTimeout () function  is used ...READ MORE

answered May 30 in Java by gaurav
• 17,760 points
65 views
0 votes
1 answer

jQuery.inArray(), how to use it right?

The jQuery inArray() method is used to find ...READ MORE

answered Jun 1 in JQuery by Edureka
• 13,640 points
33 views
0 votes
1 answer

Which keycode for escape key with jQuery

27 is the code for the escape key. ...READ MORE

answered Jun 1 in JQuery by Edureka
• 13,640 points
81 views
0 votes
1 answer

JQuery opposite of extend (reduce objects)

There is no such function, but you ...READ MORE

answered Jun 2 in JQuery by Edureka
• 13,640 points
15 views
0 votes
1 answer

How to check a radio button with jQuery?

“jquery datepicker format” Code Answer's $('#timePicker'). datetimepicker({ // dateFormat: ...READ MORE

answered Jun 10 in JQuery by gaurav
• 17,760 points
22 views
0 votes
1 answer

How to distinguish between left and right mouse click with jQuery

Using the mousedown() method: The mousedown() method in ...READ MORE

answered Jun 14 in JQuery by gaurav
• 17,760 points
29 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP