Keystroke

Advanced

Phrases that do more than plain text: today's date, whatever you last copied, a pick list, a short form. Start with the getting started page if you have not used Keystroke before.

How these are set up. Every phrase is a few lines in your phrase file, and the Keystroke editor writes them for you. Dates, times, what you last copied and where the cursor waits are made in the editor with the Insert button, beside "Text it becomes". The rest on this page are not in the editor yet, so each shows the lines that go into the file.

The examples here use shortcuts that start with a semicolon, so they fire the moment you finish typing; any shortcut works, as the getting started page explains.

To add one: open your phrase folder, open the phrase file (it ends in .yml) in Notepad, and paste the example under the line matches:, with two spaces in front of every line so it lines up with the phrases already there. Save the file and the phrase works straight away. Or ask whoever looks after your Keystroke to add it for you.

Contents

  1. More ways to trigger a phrase
  2. Dates and times
  3. What you last copied
  4. Where the cursor lands
  5. One phrase inside another
  6. A different wording each time
  7. Pick from a list
  8. Fill in the blanks
  9. Run a command
  10. Not in Keystroke yet

More ways to trigger a phrase

Two shortcuts for the same phrase

Useful when you cannot remember which one you picked.

You type

;addr or ;address

You get

1 Example Street, Sampletown, AB1 2CD

Set up

- triggers: [";addr", ";address"]
  replace: "1 Example Street, Sampletown, AB1 2CD"

Following your capitals

Type the shortcut in lower case, with a capital first letter, or in capitals, and the phrase follows: although, Although, ALTHOUGH.

You type

;alh

You get

although

Set up

- trigger: ";alh"
  replace: "although"
  propagate_case: true

Dates and times

A date phrase is written once and gives the right date every day. The results below are from Tuesday 29 September 2026, just before 9.30am.

You typeYou getFormat
;today29/09/2026%d/%m/%Y
;longdateTuesday 29 September 2026%A %-d %B %Y
;isodate2026-09-29%Y-%m-%d (sorts correctly in file names)
;time09:24%H:%M
;time129:25 am%-I:%M %p
;weekWeek 40Week %V
;tomorrowWednesday 30 September%A %-d %B, moved on one day
;nextweekTuesday 6 October%A %-d %B, moved on seven days

Setting one up

In the editor: put the cursor where the date should go, click Insert and choose Today's date, Tomorrow's date or Time now. A marker such as {{date}} appears in the text, and a box underneath lets you choose the day (today, tomorrow, yesterday, a week today) and the style, shown as real examples. The date can sit inside a sentence: Sent on {{date}}.

The editor offers the six styles in the first table. For any other, the lines below go into the phrase file.

Today, as 29/09/2026

- trigger: ";today"
  replace: "{{d}}"
  vars:
    - name: d
      type: date
      params:
        format: "%d/%m/%Y"

Tomorrow, as Wednesday 30 September

- trigger: ";tomorrow"
  replace: "{{d}}"
  vars:
    - name: d
      type: date
      params:
        format: "%A %-d %B"
        offset: 86400

Every date and time code

Put these together in any order, with any spaces, slashes or words between them. Results are from 9.25am on Tuesday 29 September 2026.

CodeGivesMeaning
%d29Day of the month, always two digits (05 on the 5th)
%-d29Day of the month, no leading zero (5 on the 5th)
%e29Day of the month, a space instead of a leading zero
%ATuesdayDay name
%aTueShort day name
%u2Day of the week as a number, Monday is 1
%m09Month number, always two digits
%-m9Month number, no leading zero
%BSeptemberMonth name
%bSepShort month name
%Y2026Year
%y26Year, last two digits
%H09Hour on the 24 hour clock, two digits
%-H9Hour on the 24 hour clock, no leading zero
%I09Hour on the 12 hour clock, two digits
%-I9Hour on the 12 hour clock, no leading zero
%M25Minutes
%S25Seconds
%pamam or pm
%j272Day of the year
%V40Week number, weeks starting on Monday (the International Organization for Standardization (ISO) numbering used in most of Europe)
%Z+01:00Time difference from Coordinated Universal Time (UTC), +01:00 during British Summer Time

Moving the date on or back

offset moves the date by a number of seconds. It counts every day, weekends included.

ForOffset
Yesterdayoffset: -86400
Tomorrowoffset: 86400
A week todayoffset: 604800
In 30 daysoffset: 2592000
In two hoursoffset: 7200

What you last copied

Puts whatever is on the clipboard into the phrase. Copy a link, type the shortcut, and the sentence arrives with the link in it. In the editor: click Insert, then What you last copied.

You copy, then type

https://example.com/page, then ;link

You get

Here is the link: https://example.com/page

Set up

- trigger: ";link"
  replace: "Here is the link: {{clip}}"
  vars:
    - name: clip
      type: clipboard

Where the cursor lands

Handy for a greeting where the name changes. In the editor: put the cursor where you will carry on typing, click Insert, then Where the cursor waits; [cursor] marks the spot. In the phrase file it is written $|$.

You type

;hi

You get

Hi |, Thanks for your message.

The cursor waits after "Hi ", ready for the name.

Set up

- trigger: ";hi"
  replace: "Hi $|$,\n\nThanks for your message."

One phrase inside another

Reuse a phrase you already have, so a change to it (a new job title, say) reaches every phrase that uses it.

You type

;thanks

You get

Thanks again. Kind regards, Alex Example

Set up

- trigger: ";thanks"
  replace: "Thanks again.\n{{sig}}"
  vars:
    - name: sig
      type: match
      params:
        trigger: ";sig"

A different wording each time

Picks one of several versions at random, so repeated messages do not all read the same.

You type

;bye

You get one of

Speak soon. Talk soon. Catch up soon.

Set up

- trigger: ";bye"
  replace: "{{b}}"
  vars:
    - name: b
      type: random
      params:
        choices:
          - "Speak soon."
          - "Talk soon."
          - "Catch up soon."

Pick from a list

A small window lists the options. Choose one with the arrow keys and Enter, or click it, and it goes into the text.

You type

;status and pick "At risk"

You get

Status: At risk

Set up

- trigger: ";status"
  replace: "Status: {{s}}"
  vars:
    - name: s
      type: choice
      params:
        values:
          - "On track"
          - "At risk"
          - "Delayed"

Fill in the blanks

A small form opens with a box for each blank. Fill them in, press Enter, and the finished text is typed. A blank can be a free text box or a list to choose from.

You type

;meet, then Sam and Monday

You get

Hi Sam, Are you free on Monday for a quick call?

Set up

- trigger: ";meet"
  form: |-
    Hi [[name]],
    Are you free on [[day]] for a quick call?
  form_fields:
    day:
      type: choice
      default: Monday
      values:
        - Monday
        - Tuesday
        - Wednesday

Each [[blank]] becomes a box. form_fields is only needed for blanks that are lists.

Run a command

Runs a Windows PowerShell command and types what it answers. This example types the day of the week.

A command runs with the same rights as you on the PC, so it can change or delete things. Only use commands you understand, and never one sent to you by someone else.

You type

;day

You get

Tuesday

Set up

- trigger: ";day"
  replace: "{{out}}"
  vars:
    - name: out
      type: shell
      params:
        cmd: "Get-Date -Format dddd"
        shell: powershell

Not in Keystroke yet

Espanso can do these, but Keystroke does not offer them yet. Ask if you want one.