This module allows you to use Ctrl+S or Cmd+S to save your forms.

The module deals with the following issues:

  • Choosing the correct button to execute the click on.
  • Capturing focus on the form and executing the button on the focused form.
  • Capturing the Enter key on text fields and submitting the relevant button rather than just submitting the form without a button.

It is important that the button is clicked rather than just submitting the form as this ensures the 'triggered_element' variable is set correctly and the correct submit code is executed where multiple buttons are used.

To install simply enable the module.

To set a button as the default button, add '#default_button' => TRUE to your button declaration in the form.

For example:

$form['my_button'] = array(
  '#type' => 'submit',
  '#value' => t('My Button'),
  '#default_button' => TRUE,
);

A massive thank you must go to johnv who helped to test this module thoroughly!

Project Information

Downloads