Is there a way to create a keyboard shortcut that would input a short defined sequence of characters into whatever text field is currently active?
Is it maybe possible to achieve this with AppleScript or Automator?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
You can do it from the substitutions list in System Prefs > Keyboard > Text, as in the example below.
The brackets are there in the example purely to make it file to the top [otherwise it gets mixed in with all my personal ones & I'd have to blur them all out]
Just hit the + button at the bottom, type to enter your trigger, then double click in the result field & type your desired output string. If you copy/paste into the output string, you can include carriage returns, for a full postal address etc, but you can't insert them manually.
Once setup, as soon as you hit the spacebar after a trigger keyword, it will auto-replace. Toggling 'correct spelling automatically' will change whether it suggests it to you before you've finished typing or not - as soon as it's recognised the correct replacement, space will trigger it, if 'auto' is on.
To avoid triggers which would otherwise be possibly confusing I always use ncsomething, historically because my originals used to be stored on NoteCards, but also now because I know of no word in English that starts with nc. So ncemail generates my email address, ncmobile for my phone number etc etc...
I've found over the years that using a distinct word is easier to remember than a very short abbreviation, unless it's one you use a lot.
As a bonus, you can also use it for spelling mistakes that aren't usually picked up by the normal spell-checker…
For example I frequently type pice instead of piece; for some reason spellcheck never picks that up so now it's in my substitutions list.
iCould is also one that gets past the checker, so I have one to fix that too, back to iCloud
Any changes you make to the substitutions list are 'live' immediately, you don't even need to close the window.
You can customize your keyboard layout with Ukelele. For my part, I've mapped
192.168.8. as that's my IP subnet at work and I type it constantly.