Summer is here
Normally I'm writing in Drafts on my Mac, so all my Keyboard Maestro (KM) macros are available to me. When I started working more on my iPad, I realized how much I missed my KM shortcuts. For example, on my Mac I can just type .ds
and a KM macro will delete the three characters and insert the current date in ISO 8601 format.
Replicating in Drafts
Drafts is my default writing space. It's the one of few apps that can look and feel the same on both macOS and iPadOS. The consistency between both platforms lessens some of the mental gymnastics I have to do in other apps when switching between my Mac and iPad.
The core of scripting in Drafts is Javascript.
.ds
shortcut in Drafts.
The code to create the date string:
// See online documentation for examples
// https://docs.getdrafts.com/docs/actions/scripting
// Add keyboard shortcut Ctrl-Opt-D to insert date
// in current cursor location
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
// need to +1 month since Jan = 00
var date = today.getDate();
dd = today.getDate()
if(dd<10) {
dd='0'+dd
}
mm = today.getMonth() + 1
if(mm<10) {
mm='0'+mm
}
yyyy = today.getFullYear()
var iso_date = yyyy + '-' + mm + '-' + dd ;
var selRange = editor.getSelectedRange();
editor.setSelectedText(iso_date);
editor.setSelectedRange(selRange[0]+iso_date.length, 0);
Drafts also allows you to assign a keyboard shortcut to an automation script. So instead of having to use the trackpad to click and run an automation, I can just use Ctrl
-Opt
-D
to trigger the automation.

I'm using Ctrl
-Opt
-D
because iOS has some default shortcuts set when using the Cmd
key and I could get other key combinations to work.