Insert Modifier Key Characters (Glyphs)

Keyboard Maestro “Insert Modifier Key Characters” Macro

Insert Modifier Key Characters.kmmacros (4.3 KB)

Trigger the macro when editing most text fields. Default trigger is ⇧⌥F5. You can select any item from the list by click or by arrow key, then press return or enter to insert it. You can select contiguous items with shift-click or non-contiguous items with command-click.
Insertion Dialog screen shot

Source of character insertion script

tell application "System Events"
  set frontApp to name of first process whose frontmost is true
end tell

set theCommand to «data utxt2318» as Unicode text
set theControl to «data utxt2303» as Unicode text
set theOption to «data utxt2325» as Unicode text
set theShift to «data utxt21E7» as Unicode text
set theEscape to «data utxt238B» as Unicode text
set theTab to «data utxt21E5» as Unicode text
set theReturn to «data utxt21A9» as Unicode text
set theEnter to «data utxt2324» as Unicode text
set ForwardDelete to «data utxt2326» as Unicode text
set BackSpaceDelete to «data utxt232B» as Unicode text
set doubleTab to tab & tab

tell application frontApp
  
  choose from list {theShift & doubleTab & "Shift", theControl & doubleTab & "Control", theOption & doubleTab & "Option", theCommand & doubleTab & "Command", theOption & theCommand & doubleTab & "Option+Command", theEscape & doubleTab & "Escape", theTab & doubleTab & "Tab", theReturn & doubleTab & "Return", theEnter & doubleTab & "Enter", ForwardDelete & doubleTab & "Forward Delete", BackSpaceDelete & doubleTab & "BackSpace"} with prompt "Pick the symbols you want:" OK button name "Insert" with multiple selections allowed
  
end tell

if result is not equal to false then
  
  set pickedSymbols to result as string
  set displaySymbols to ""
  if pickedSymbols contains "Shift" then
    set displaySymbols to displaySymbols & theShift
  end if
  if pickedSymbols contains "Control" then
    set displaySymbols to displaySymbols & theControl
  end if
  if pickedSymbols contains "Option" then
    set displaySymbols to displaySymbols & theOption
  end if
  if pickedSymbols contains "Command" then
    set displaySymbols to displaySymbols & theCommand
  end if
  if pickedSymbols contains "Escape" then
    set displaySymbols to displaySymbols & theEscape
  end if
  if pickedSymbols contains "Tab" then
    set displaySymbols to displaySymbols & theTab
  end if
  if pickedSymbols contains "Return" then
    set displaySymbols to displaySymbols & theReturn
  end if
  if pickedSymbols contains "Enter" then
    set displaySymbols to displaySymbols & theEnter
  end if
  if pickedSymbols contains "Forward Delete" then
    set displaySymbols to displaySymbols & ForwardDelete
  end if
  if pickedSymbols contains "BackSpace" then
    set displaySymbols to displaySymbols & BackSpaceDelete
  end if
  
  tell application "System Events"
    tell process frontApp
      set the clipboard to displaySymbols
      keystroke "v" using {command down}
    end tell
  end tell
  
end if
2 Likes

It’s probably a good idea if you included an explanation.

This inserts characters? Does it insert all modifier characters at once, or do I get to pick? Anything else you can think of would help.

And how about a screenshot of the dialog?

Scope is when editing most text fields. You can select any item from the list by click or by arrow key, then press return or enter to insert it. You can select contiguous items with shift-click or non-contiguous items with command-click.

@JMichaelTX - You’re better at explaining this than I am. When you get a chance, can you jump in? Thanks.

Dan, looks like @Lantro has responded to your request. The purpose and use of the macro now seems clear.

@Lantro, please put your scripts in a code block like this:

 ```applescript
 -- your code here

I will revise your post to do this, this time.

Cool. He's changed quite a bit since I tagged you.

@Lantro - Much clearer, especially with @JMichaelTX fixing the AppleScript . Thanks!

By the way - this looks useful to me. Thanks for posting it. I've wished I had something like this. Now I do. :slight_smile:

Here is another approach to pasting the modifier key characters, also known as "glyphs":

Dammit! See, this is why I never get anything done. "Look! Shiny Object Over Here!"

:stuck_out_tongue:

1 Like