Useful macOS defaults: Keyboard

Keyboard settings are spread across several domains. The main ones are NSGlobalDomain and com.apple.keyboard.

After changing these, log out and back in.

Key repeat speed

Set how fast a key repeats when held down. Lower values mean faster repeat:

defaults write NSGlobalDomain KeyRepeat -int 2

Common values:

Delay before key repeat starts

Set how long you hold a key before it starts repeating:

defaults write NSGlobalDomain InitialKeyRepeat -int 15

Common values:

Use function keys as standard function keys

By default, the top row keys control brightness, volume, and so on. To make them act as F1, F2, F3 instead (and require holding Fn for brightness and volume):

defaults write NSGlobalDomain com.apple.keyboard.fnState -bool true

Set to false to go back to the special features being the default.

Remap the Caps Lock key

You can remap Caps Lock to Escape, Control, or other keys. This is popular with Vim users.

Unfortunately, the key mapping is stored in a complex format per keyboard. The simplest way is through System Settings, then Keyboard, then Keyboard Shortcuts, then Modifier Keys.

Turn off auto-correct

defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

Turn off smart quotes

defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

Turn off smart dashes

defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false

Turn off automatic capitalisation

defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false

Turn off adding a full stop with double space

defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false

All text corrections at once

Turn off everything at once:

defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticTextCompletionEnabled -bool false

Full keyboard access

Let Tab move focus through all controls on screen (buttons, dropdowns, and so on), not just text fields:

defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

Values:

This is useful for navigating dialog boxes without touching the mouse. You can press Space to click a focused button.

Globe key behaviour

On keyboards with a Globe key (fn), set what it does:

defaults write com.apple.HIToolbox AppleFnUsageType -int 0

Values:

Keyboard brightness

Turn off automatic keyboard backlight adjustment:

defaults write com.apple.keyboard KeyboardBrightnessAutoAdjust -bool false

Set the keyboard backlight timeout (in seconds of inactivity before the backlight turns off). Set to 0 to keep it on:

defaults write com.apple.keyboard KeyboardBrightnessTimeout -int 60

Press and hold for accented characters

When you press and hold a letter key, macOS shows a popup with accented versions (like holding "e" to get é, è, ê). To turn this off and get key repeat instead:

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

To bring back the accent popup:

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool true

Read all current keyboard settings

defaults read NSGlobalDomain | grep -i key
defaults read NSGlobalDomain | grep -i automatic
defaults read com.apple.keyboard

Notes

Key repeat and initial delay values do not map neatly to milliseconds. The numbers above are the internal codes macOS uses. The System Settings sliders set these same values. The fastest settings through System Settings are KeyRepeat 2 and InitialKeyRepeat 15. You cannot go faster through defaults either.

Text correction settings (NSAutomatic*) live in NSGlobalDomain and affect all apps. Individual apps can override them, but the global setting is the default for new apps.


Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.


Tags

Category:

Year: