Saving with keyboard shortcuts

August 30, 2012 by Jukka Svahn

Julián posted little tip in bot_wtc plugin’s support thread. This tip contained a snip of code that allowed you to save admin-side editor forms using CTRL+S keyboard shortcut. He also pointed out that it made ideal companion for rah_expanding’s dynamic fields, which I do agree with.

I thought that this idea was so good that I threw some code to a git repository and put it up to GitHub. I called it rah_knots after Command+S shortcut, a name that actually hints why I made the repository.

Now when Textpattern 4.5 is out and has asynchronous background events, having keyboard shortcuts makes some serious sense. Why should we have to scroll and find that tiny save button? No reason. The page isn’t going to reload when you send the form. But what if Julián’s tip and Jon-Michael Deldin’s original code was given bit of a facelift and made even better? This is where rah_knots comes in.

Love me some fairy fruit

First thing I noticed is that the Julián’s updated code didn’t support Command key. A comment in the code told it did, which it was correct on, but only on WebKit. On Firefox the shortcut would have brought up your normal Save As dialog, and Firefox on Mac is the browser I mainly use. This ain’t going to fly, I said in my head.

Remind me again

After sorting the dialog issue on Firefox and given the code some clean up, I used my head to think, or would have if my brain didn’t forget what I was thinking. Oh, yeah – I added a tiny shortcut tip. One that told about the keyboard shortcut. One that appears when you hover over a save button, fades in smoothly and stays out of the way.

A thing that might not sound surprising is that this save shortcut is limited just to certain forms. Well, to one editor form per a page. We could do some crazy checking with focuses, last edits or even send all forms at once, but that honestly may not be the best idea. You eventually end up saving the wrong items by accident or run into compatibility issues. To reduce confusion where the shortcut works, and to act as a reminder about its existence, I added this tiny tip. Helps us scatterbrains and aging dogs.

Get it now

You can follow potential future development and download rah_knots on GitHub. Fair warning, the code is pretty “experimental” and while it shares a rah prefix, it’s not really part of the main product line. Use at your own risk.