Mac OS X Keybinding Action Code

By Xah Lee. Date: . Last updated: .

This page lists the action codes for creating keybindings on OS X.

[see Mac: How to Change Keybinding]

Action can be inserting a character, a string, moving the cursor by character, word, line, or page up/down, or open file, create new file, etc.

Text insertion

/* insert a string */
("insertText:", "good morning");
/* insert a Unicode character that has hex code 03B1 */
("insertText:", "\U03B1");

To find the character and the hexadecimal code you want, see: Unicode Characters ∑ ♥ 😄.

Cursor movement

Sample code:

{
"\UF729" = "moveToBeginningOfLine:"; /* home key */
"\UF72B" = "moveToEndOfLine:"; /* end key */
}

Move Cursor and Extend Selection

Most (or all) of these actions also have a version with suffix “AndModifySelection”. For example, there's

These are the same as moving cursor but also extend the selection.

{
"\UF729" = "moveToBeginningOfLine:";
"\UF72B" = "moveToEndOfLine:";

"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

For left-to-right languages, there's no difference between “moveLeft” and “moveBackward”. The “moveBackward” is for moving in the backward direction of the language flow.

Whenever there's a “Up”, there's also a “Down” version. Similarly, “Backward” with “Forward”, “Beginning” and “Ending”. In the following, these reverse versions omitted.

Moving the screen

Text editing

Text Transformation

Common Mac Operations

Sequence of Actions

You can create a sequence of actions, like this:

/* insert bracket pairs and move cursor in-between */
"~k" = ("insertText:", "()", "moveLeft:");

/* copy all file content */
"~c" = ("selectAll:", "copy:");

For key syntax, see: Mac OS X Keybinding Key Syntax.

back to Mac: How to Change Keybinding

Did i $save$ you from getting a brick?

$5 me, at patreon
or paypal to xah@xahlee.org

If you have a question, put $5 at patreon and message me.

  1. Ergo Keyboards
  2. PC Keyboards
  3. Fun Keyboards
  4. Keypads
  5. Do-It-Yourself
  6. History
  7. Design
  8. Layout
  9. Keybinding
  10. Typing
  11. Key How-To
  12. Mouse
  13. Trackball
  14. Trackball History
  15. Misc
  16. Blog