Type Sequence of Keys

Type sequence of keys

This subroutine types the key for each character in the supplied string (which may include both the standard Apple symbols for control characters and a macro to represent duplicate characters).

It can be useful for navigating menus programatically when other methods aren't appropriate, as it allows for cursor movements to be specified numerically (and hence by variable).

The following control characters are mapped onto their key equivalent. The standard Apple symbols are used - together with a pause symbol (either the Unicode "pause symbol" or the SF symbol "pause.circle" will work):

  • ↑: Up
  • ↓: Down
  • ←: Left
  • →: Right
  • ⇥: Tab right
  • ⇤: Tab left (back tab)
  • :arrow_upper_left:︎: Top/Home (this may render differently in the wiki)
  • ︎↘: End
  • ︎⇞: Page Up
  • ⇟: Page Down
  • ⏎: Return (see the note below)
  • ⎋: Escape
  • ⌫: Delete
  • ⌦: Forward Delete
  • :pause_button:: Pause for 0.2s (either the Unicode "pause symbol" or the SF symbol "pause.circle" can be used)

By default, there is no pause between key presses, but the optional "Pause between each key" parameter can be set (in seconds) to pause between every key press, and individual pause symbols can be used to introduce a 0.2s pause between particular key presses.

Any character which isn't shown above as a control character will pass through and be typed normally.

A character which is followed by a number between 0..99 in curly braces will be duplicated by that amount (using the Duplicate characters in a string subroutine below). For example: "↓{3}→↓{2}⏎" becomes "↓↓↓→↓↓⏎".

The standard Unicode "RETURN SYMBOL" glyph (⏎) is used for the Return key (note that it may render differently depending upon the font used). The other symbol sometimes used to represent the macOS Return key – the Unicode "LEFTWARDS ARROW WITH HOOK" glyph (:leftwards_arrow_with_hook:︎) – cannot be used as an alternative as it appears to be treated specially by Keyboard Maestro.

Download the "Type sequence of keys" subroutine (23 KB)

Show the macro

Duplicate characters in a string

Expands characters in a string by a specified amount. For example: "↓{3}→↓{2}⏎" becomes "↓↓↓→↓↓⏎".

Download the "Duplicate characters in a string" subroutine (7.8 KB)

Show the macro