MacOS: Create Custom Keyboard Layout
Here is a example of ErgoEmacs Keybinding, one for QWERTY layout and one for Dvorak Keyboard Layout:
Extended Accent Codes for Mac
The U.S. Extended keyboard allows you to types accented carons (č), ogoneks (ą), dots (ṭ), thorns (þ) and others.
This page includes instructions for activating the Extended Keyboard and its codes.
Page Content
- Student Computing Labs
- Activate Extended Keyboard
- Extended Keyboard Accent Codes
- Combining Diacritics – Makes any combination, but there may be display issues
Student Computing Labs
Follow the instructions below to activate different keyboards as needed. They will remain active in your profile between logins. See the Macintosh Computing Lab page to see which Mac operating system is installed.
Activate Extended Keyboard
To use these codes, you need to activate the U.S. Extended keyboard (or ABC Extented in El Capitan) in the System Preferences following the instructions below.
Note: Some codes may not work if the software or Web site does not fully support Unicode.
Activate U.S. Extended Keyboard in Yosemite/Mavericks
See the Mac Keyboard instructions for activation instructions before Mavericks.
- Go to the Apple menu and open Systems Preferences.
- Click the Languages and Regions (U.N. flag) icon on the first row of the Systems Preferences panel.
- lick the Keyboard Preferences button at the bottom of the window to open the keyboard preferences.
- Click the Input Sources tab.
- Click the + putton to see a list of languages with keyboards. The U.S. Extended keyboard is listed under English. Click Add to ensure that they keyboard is activated.
Switch Keyboards
- Make sure you have activated all the appropriate keyboards following the instructions in the previous section.
- Open a software application such as a word processor, spread-sheet or any other application in which you need to enter text.
- On the upper right portion of the screen, click on the American flag icon ( ). Use the dropdown menu to select the U.S.Extended Keyboard ( ).
- The keyboard will be switched and an appropriate font will be selected within the application. A flag icon corresponding to the keyboard will be displayed on the upper right.
- To switch back to the standard U.S. keyboard or to some other keyboard, click on the flag icon on the upper right and select a keyboard from the dropdown menu.
Note on Fonts
Many of the fonts from Apple, Adobe and Unicode friendly fonts include the extended accents, but some older fonts or decorative fonts may be missing characters. Check your documents carefully to be sure formatting is consistent.
Extended Keyboard Codes
Note: If these codes are not working, then please make sure you have activated and switched to the extended keyboard following the instructions above.
ACCENT | SAMPLE | TEMPLATE | NOTES |
---|---|---|---|
Circumflex | Ŵ,ŵ | Option+6,X | Works with many letters including W.. Note difference from Option+I in U.S. Standard keyboard. |
Accented Y | Ý,Ÿ | See Notes | Use Option+E for acute Y and Option+U for umlaut Y |
Macron | Ō,ō | Option+A, X | Latin long mark, plus long Y (Ȳ) and long ash (Ǣ). Use Option+K,A if you need A-ring. |
Breve | Ŏ,ŏ | Option+B, X | Short vowel mark |
Arch (inverted Breve) | Ȏ,ȏ | Shift+Option+S, X | Appears over vowels |
Nasal Vowel Tilde | Ẽ,ẽ | See Notes | Use Option+N to place a tilde over any vowel including E,I |
Hacheck | Č,č | Option+V, X | Used in Czech and other languages |
Cedilla/Cedille | Ş,ş | Option+C, X | Works with S and other letters as well as C |
Polish Ogonek | Ą,ą | Option+M, X | Used in Polish for nasal vowels. Reverse of French cedille |
A ring, U ring | Ů,ů | Option+K, X | U ring in Czech; A-ring in Scnadinavian languages |
Hungarian Double Acute | Ő,ő | Option+J, X | Appears only over O,U |
Double Grave | Ȍ,ȍ | Shift+Option+Y, X | Tone marker in some Slavic languages. Works with vowels plus R. |
Strikethrough Bar | ł,ɨ | Option+L, X | Works with L,I,O |
Subscript Dot | ṣ,ḍ | Option+X, X | Used to indicate retroflex consonants |
Superscript Dot | ṡ,ḟ, | Option+W, X | Used in Polish and Old Irish. |
Thorn | þ,Þ | Option+T Shift+Option+T |
Used in Icelandic and Old English |
Eth | ð,Ð | Option+D Shift+Option+D |
Used in Icelandic and Old English |
Combining Diacritics
These codes add accents to ANY Letter via Unicode combining characters (glossary). As a result, there may be unusual display issues with certain fonts or certain letters (e.g. capital letters).
To use these codes first type the letter, then type the code.
NOTE: If these codes are not working, then please make sure you have activated and switched to the extended keyboard following the instructions above.
ACCENT | SAMPLE | TEMPLATE |
---|---|---|
Combining Acute | V́,v́ | Shift+Option+E |
Combining Double Acute | V̋,v̋ | Shift+Option+J |
Combining Grave | V̀,v̀ | Shift+Option+` |
Combining Umlaut/Diaresis | V̈,v̈ | Shift+Option+U |
Combining Circumflex | V̂,v̂ | Shift+Option+6 |
Combining Tilde | Ṽ,ṽ | Shift+Option+N |
Combing Caron/Hachek | V̌,v̌ | Shift+Option+V |
Combining Macron | V̄,v̄ | Shift+Option+A |
Combining Macron Below | J̱,j̱ | Shift+Option+H |
Combining Breve | V̆,v̆ | Shift+Option+B |
Combining Cedille | V̧,v̧ | Shift+Option+C |
Combining Ogonek | V̨,v̨ | Shift+Option+M |
Combining Ring Above | V̊,v̊ | Shift+Option+K |
Combining Stroke | V̵,v̵ | Shift+Option+L |
Superscript Dot Above | V̇,v̇ | Shift+Option+W |
Combining Dot Below | J̣,j̣ | Shift+Option+X |
Combining Comma Below | V̦,v̦ | Shift+Option+I |
Combining Horn | V̛,v̛ | Shift+Option+I |
macOS: Create Custom Keyboard Layout
MacOS has a system-wide way to let you define or modify shortcut keys for text editing operations.
You can create keys to:
- Insert math symbols, emoji, or any template text.
- Move cursor by word, page up/down.
- Copy, cut, paste, undo, redo.
- select word, line, paragraph, select all.
- upcase word, lowercase word.
- new, open, save, etc.
- and more.
Key Config File
Create a file at
Create the “KeyBindings” folder if you don’t already have it.
Copy and past the following:
/* -*- coding: utf-8 -*- */ < /* insert Unicode character with Option key down */ "~h" = ("insertText:", "♥"); "~t" = ("insertText:", ""); "~c" = ("insertText:", ""); "~s" = ("insertText:", ""); /* move cursor with i j k l keys while Ctrl key down */ "^i" = ("moveUp:"); "^k" = ("moveDown:"); "^j" = ("moveLeft:"); "^l" = ("moveRight:"); >
Note: if you use Unicode Characters such as ♥ directly in the file , you must save the file using UTF-8 encoding.
macOS TextEdit save utf8 2020-07-25 TextEdit app
Launch or restart TextEdit or other app to start to use your changes.
The syntax in general is this:
/* this is comment */ < keycode1 = actionCode1; keycode2 = actionCode2; >
- keycode is a string that represents key press.
- actionCode represents what to do.
Keycode Syntax
Action Code
Unicode Reference
If you want to create lots keys to insert math symbols or emoji, see
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 is 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 http://example.com/\n\n☄"); >
Here is a example of ErgoEmacs Keybinding, one for QWERTY layout and one for Dvorak Keyboard Layout:
- ErgoEmacs_keybinding_os_x_qwerty.dict.txt
- ErgoEmacs_keybinding_os_x_dvorak.dict.txt
You can look at Xcode’s keybinding file at /Developer/Applications/Xcode.app/Contents/Resources/PBKeyBinding.dict . You can view it here: osx_keybinding_xcode.dict.txt .
Emacs Keybinding
Mac OS X by default support emacs keybindings. They are:
Ctrl + f Move forward Ctrl + b Move backward Ctrl + n Move down a line Ctrl + p Move up a line Ctrl + a Beginning of line Ctrl + e End of line Ctrl + k Delete current position to end of line Ctrl + y Paste
You can add more of emacs’s
Ctrl + space Set mark Ctrl + w Cut Ctrl + x Ctrl + x Swap 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, try: Emacs: Xah Fly Keys .
Problems
Something this cannot do. For example:
- It cannot remap keys.
- It can’t set a key such as F8 to type other keys such as ⌘ command + c .
- It can’t set a key to launch a app or script.
There are many solutions to these. See: Mac Keyboard Software Guide
Best is to get a programable keyboard. See: Programable Keyboards with Onboard Memory
Reference
- Text System Defaults and Key Bindings By Apple. At https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
- Technical Note TN2056: Installable Keyboard Layouts At https://developer.apple.com/library/mac/technotes/tn2056/_index.html
Mac Keyboard Guide
- Mac Keyboard Software Guide
- Mac: Swap CapsLock Control Option Command Keys
- macOS: Create Custom Keyboard Layout
- Mac Keyboard Viewer
- Mac: How to Switch to Dvorak Keyboard Layout
- Mac: Hover Mouse Auto Click
- Mac Keyboard Shortcuts
- Apple Keyboard Problems
- Apple Keyboard History ⌨
- Difference Between Apple and Microsoft keyboards
How-to: Bash Keyboard Shortcuts
For example, to move to a directory ‘sample1’; Type cd sam ; then press TAB and ENTER .
type just enough characters to uniquely identify the directory you wish to open.
Special keys: Tab, Backspace, Enter, Esc
Text Terminals send characters (bytes), not key strokes.
Special keys such as Tab, Backspace, Enter and Esc are encoded as control characters.
Control characters are not printable, they display in the terminal as ^ and are intended to have an effect on applications.Ctrl+I = Tab
Ctrl+J = Newline
Ctrl+M = Enter
Ctrl+[ = EscapeMany terminals will also send control characters for keys in the digit row:
Ctrl+2 → ^@
Ctrl+3 → ^[ Escape
Ctrl+4 → ^\
Ctrl+5 → ^]
Ctrl+6 → ^^
Ctrl+7 → ^_ Undo
Ctrl+8 → ^? Backward-delete-charCtrl+v tells the terminal to not interpret the following character, so Ctrl+v Ctrl-I will display a tab character,
similarly Ctrl+v ENTER will display the escape sequence for the Enter key: ^M
History:
Ctrl + r Recall the last command including the specified character(s) searches the command history as you type. Equivalent to : vim ~/.bash_history. Ctrl + p Previous command in history (i.e. walk back through the command history) Ctrl + n Next command in history (i.e. walk forward through the command history) Ctrl + s Go back to the next most recent command. (beware to not execute it from a terminal because this will also launch its XOFF). Ctrl + o Execute the command found via Ctrl+r or Ctrl+s Ctrl + g Escape from history searching mode !! Repeat last command !n Repeat from the last command: args n e.g. !:2 for the second argumant. !n:m Repeat from the last command: args from n to m. e.g. !:2-3 for the second and third. !n:$ Repeat from the last command: args n to the last argument. !n:p Print last command starting with n !$ Last argument of previous command ALT + . Last argument of previous command !* All arguments of previous command ^abc^def Run previous command, replacing abc with def
Process control:
Ctrl + C Interrupt/Kill whatever you are running (SIGINT) Ctrl + l Clear the screen Ctrl + s Stop output to the screen (for long running verbose commands) Ctrl + q Allow output to the screen (if previously stopped using command above) Ctrl + D Send an EOF marker, unless disabled by an option, this will close the current shell (EXIT) Ctrl + Z Send the signal SIGTSTP to the current task, which suspends it. To return to it later enter fg 'process name' (foreground).
To use the Alt Key Shortcuts in macOS – Open Terminal Preferences ➞ Settings Tab ➞ Keyboard ➞ Tick “Use option as meta key”
Custom Terminal Keyboard Shortcuts
- Press + to add a new entry
- Select the keyboard shortcut
- Set the Action to Send Text
- Enter the escape sequence: \033[H (for Start of Line) or \033[F (for End of Line)
Emacs mode vs Vi Mode
All the above assume that bash is running in the default Emacs setting, if you prefer this can be switched to Vi shortcuts instead.
Set Vi Mode in bash:
$ set -o vi
Set Emacs Mode in bash:
$ set -o emacs
“. emacs, which might be thought of as a thermonuclear word processor” ~ Emacs vs. Vi Wiki
Related macOS commands
How-to: Keyboard Shortcuts for macOS.
Apple Kb HT201236 – Keyboard Shortcuts Quick Reference.
fg – Bring a command to the foreground.
vi editor – A one page reference to the vi editor.
~./.bash_history – Text file with command history.
Comments are closed, but trackbacks and pingbacks are open.