Mac: How to Change Keybinding

By Xah Lee. Date: . Last updated: .

MacOS has a system-wide mechanism to let youyou define or modify the shortcut keys for text editing operations.

It lets you create keys to:

Mac keyboard viewer us int 2017  41373
Mac keyboard viewer, with ⌥ option key down, you can define your own symbols.

[see Mac Keyboard Viewer and Unicode]

Key Config File

Create a file at


Create the “KeyBindings” folder if you don't already have it.

Copy and past the following:

/* insert Unicode character with Option key down*/
"~;" = ("insertText:", "\U2665"); /* heart */

/* move cursor with i j k l keys while Ctrl key down */
"^i" = ("moveUp:");
"^k" = ("moveDown:");
"^j" = ("moveLeft:");
"^l" = ("moveRight:");

Restart a application and the new keybinding will take effect in that application.

Launch TextEdit to test your changes.

Note: Only applications that uses Cocoa Text System will support this.

Note: if you use Unicode Characters directly in the file such as , you must save the file using UTF-8 encoding.

The syntax in general is this:

/* this is comment */
"keycode1" = actionCode1;
"keycode2" = actionCode2;

Key Syntax

Mac OS X Keybinding Key Syntax

Action Code

Mac OS X Keybinding Action Code

Unicode Reference

If you want to create lots keys to insert math symbols or emoji, see

Unicode Characters ∑ ♥ 😄

Sample File

Example of defining the {Home, End} keys to move to the beginning/end of line.

/* make home/end key to move to begin/end of line */

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

Here's example file for inserting Unicode characters with the ⌥ option key.

/* -*- coding: utf-8 -*- */

/* insert Unicode characteres with Option key down */
"~#8" = ("insertText:", "↑");
"~#2" = ("insertText:", "↓");
"~#4" = ("insertText:", "←");
"~#6" = ("insertText:", "→");

"~a" = ("insertText:", "α");
"~h" = ("insertText:", "θ");

"~3" = ("insertText:", "†");
"~7" = ("insertText:", "—");
"~8" = ("insertText:", "•");
"~9" = ("insertText:", "★");

"~&" = ("insertText:", "‣");
"~*" = ("insertText:", "°");

/* insert pairs with Option down */
"~d" = ("insertText:", "«»", "moveBackward:");
"~h" = ("insertText:", "{}", "moveBackward:");
"~t" = ("insertText:", "()", "moveBackward:");
"~n" = ("insertText:", "[]");
"~s" = ("insertText:", "“”", "moveBackward:");
"~-" = ("insertText:", "「」", "moveBackward:");

"~D" = ("insertText:", "‹›", "moveBackward:");
"~S" = ("insertText:", "‘’", "moveBackward:");
"~_" = ("insertText:", "『』", "moveBackward:");

/* insert sig */
"~1" = ("insertText:", "  John\n\n\n☄");

Here's a example of ErgoEmacs Keybinding, one for QWERTY layout and one for Dvorak Keyboard Layout:

You can look at Xcode's keybinding file at /Developer/Applications/ You can view it here: osx_keybinding_xcode.dict.txt.

Emacs Keybinding

Mac OS X by default support emacs keybindings. They are:

Mac OS X's default emacs keybindings
Ctrl+fmove forward
Ctrl+bmove backward
Ctrl+nmove down a line
Ctrl+pmove up a line
Ctrl+abeginning of line
Ctrl+eend of line
Ctrl+kdelete current position to end of line

You can add more of emacs's

Ctrl+spaceset mark
Ctrl+x Ctrl+xSwap cursor position to last mark

However, i don't recommend it. Emacs's keys is very inefficient and ergonomically painful. See: Why Emacs's Keyboard Shortcuts are Painful. If you like a efficient keybinding for text editing, you might try: ErgoEmacs Keybinding.


Something this cannot do. For example:

There are many solutions to these. See:

Mac: Key Remapping, Keybinding Tools

Best is to get a programable keyboard.

see Programable Keyboards with Onboard Memory

See: Problems of Mac OS X's Keybinding Scheme DefaultKeyBinding.dict.


back to Keyboard Shortcut and Layout Tutorial

Apple/Mac Keyboard Topic

  1. Mac: Keyboard/Automation Tools
  2. Mac: Swap Control, Caps Lock, Option, Command Keys
  3. Mac: How to Change Keybinding
  4. Mac Keyboard Viewer and Unicode
  5. Mac: How to Switch to Dvorak Keyboard Layout
  6. Mac: Hover to Switch Window
  7. Mac Keyboard Shortcuts
  8. Apple Keyboards ⌨
  9. Apple Keyboard History ⌨
  10. Difference Between Apple and PC keyboards
Did i $save$ you from getting a brick?

$5 me, at patreon
or paypal to

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