Craft Quick Tip: Add Ctrl-s Support to Your Plugin Forms

Published on 2nd September, 2014

One of Craft’s many pleasant surprises is its support for the standard “save” keyboard shortcut. Hit CTRL-S1 on any form, and Craft behaves just as if you’d clicked the save button. Neat.

Pretty soon, this behaviour becomes a basic expectation. It’s also around this time that people start complaining your plugin is broken, because it doesn’t save when they press CTRL-S.

Thankfully, Craft makes it trivially easy to add this functionality to your own plugin forms. Just add data-saveshortcut=12 to the opening form tag, and you’re done:

<form method="post" data-saveshortcut="1">

  1. If you’re on a Mac, CMD-S also works. ↩︎

  2. As of Craft 2.2, you can just use data-saveshortcut↩︎