dotfiles: Key repeat broken in macOS Sierra

Currently your script…

defaults write NSGlobalDomain KeyRepeat -int 0

…does not work in macOS Sierra. I’ve found that if I set things up here they work great:

screen shot 2016-07-14 at 10 20 05 am

Maybe they changed the preference file location or something.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 19
  • Comments: 65 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I have come to this thread looking for a solution to my big issue with the macos Sierra update I’ve recently done, to find a dismal scene. It appears Apple has altered the scaling factors of keyboard repeat rate and wait-times, in a way that has implications for power users everywhere: If you rely on your keyboard as a principle means of interfacing with your computer, your system will now feel slower, no matter what you do.

Just in case anyone at Apple GIAF’s, this nonsense with the key repeat rate has the (intended/un-?) impact of making Apple computers feel slower, for those of us who use keyboard-based applications (apparently there are still a few…) For example, I feel that through todays usage of vim, as opposed to yesterdays pre-Sierra update, my computer is about 3x slower than it was. In actuality, it is not - but it certainly is not sending keys to my apps as fast as it used to, so my apps spend a lot more time just sitting around … waiting for keypress.

It really seems like a systematic failure on Apple’s part to not understand this. I guess in the leap for features (sticky-/hot-keys are a feature now?) and the desire to push Siri everywhere, Apple is preparing us to have the courage required to … get rid of the keyboard, too?

@mathiasbynens defaults write NSGlobalDomain KeyRepeat -int 1 is the best I can do on macOS Sierra. The float just doesn’t work.

I found that locking and unlocking my macbook was enough to apply the changes.

defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10

Seems as fast as before for me once I locked and unlocked my computer.

In Sierra you can unplug and replug your external keyboard in for the new values to take effect, no reboot required.

I’m running macOS Sierra 10.12.3, and I concur with @lucascaton. The solution to get the fastest keypress speeds all around is to run the following in your terminal (you can copy-paste the below directly, but note it will restart your computer):

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false && \
defaults write NSGlobalDomain KeyRepeat -int 1 && \
defaults write NSGlobalDomain InitialKeyRepeat -int 10 && \
sudo reboot

When I attempted lower int values for either KeyRepeat or InitialKeyRepeat, I kept running into issues where my Mac Pro’s 4k display literally wouldn’t work at all and/or I had to physically reboot my comp (sidenote: potentially an odd/interesting bug? how/why would keypress settings affect display function?)

For me:

defaults write NSGlobalDomain KeyRepeat -int 1 defaults write NSGlobalDomain InitialKeyRepeat -int 10

makes it blazing fast. Even a bit too much, maybe.

@kvpb Yeah, using float seems to work (as in, fast keyboard repeat is enabled by it after a reboot):

defaults write NSGlobalDomain KeyRepeat -float 0.000000000001; defaults read-type NSGlobalDomain KeyRepeat; defaults read NSGlobalDomain KeyRepeat
Type is float
1e-12

For posterities sake, the following are the macOS 10.12.1 step values for the keyRepeat and InitialKeyRepeat when you set them using the GUI. Lower values are faster.

keyRepeat: 120, 90, 60, 30, 12, 6, 2 InitialKeyRepeat: 120, 94, 68, 35, 25, 15

@anhkind @knpwrs @danemacmillan @kdeldycke If you want to close to 0 try this:

defaults write NSGlobalDomain KeyRepeat -int 1

It is as close as you can get on macOS Sierra.

I’ve played with that a bit. I think 0 is no longer allowed as a value, but you could use 1, 2 etc. It makes it awfully fast then though. So they might have changed the scale. If you set it to the fastest Key Repeat and shortest initial delay and then read the values on the command line you get 2 and 15.

@jakeonrails Thanks for that! Worked like a charm on a Mac Pro.

Here’s what I ended up with to correct the problem, using your suggestion.

# Set a blazingly fast keyboard repeat rate.
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false;
defaults write -g InitialKeyRepeat -int 15; # Anything lower than 15 seems too fast.
defaults write -g KeyRepeat -int 2; # You can go as low as 1, but that's too darn fast for me.

Same here. I just ugpraded to Sierra and I had to use… the GUI. And even then key repeat wasn’t as fast as it was in El Capitan.

@jdsimcoe Could you do this please?

  1. defaults read > a
  2. Open system preferences and change the setting to some other value than the default.
  3. defaults read > b
  4. Post diff a b here.

Logging in and out is enough, don’t need a full restart.

Just have in mind that you need to restart to apply the changes.

Finally found a solution! 🎉

defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

Then, close the app and re-open it.

Hey everybody.

I just got off the phone with Apple Support about this issue. Rubber ducking the problem with a very helpful agent named Zach, I resolved this problem for my computer on OS X Sierra.

The trick was:

defaults write -g KeyRepeat -int 1

followed by a reboot.

Does that fix it for anyone else? I think the reboot step is critical.

@seclorum Apple stopped supporting developers like us aeons ago. Look at Swift Playgrounds on the App store.

In case you guys found default ./.macos setting is too fast. Here is good setting:

defaults write NSGlobalDomain KeyRepeat -int 3
defaults write NSGlobalDomain InitialKeyRepeat -int 20

FOUND THE SOLUTION

After being desperate myself, I tried out every single solution which was posted here, but nothing helped. Afterwards, I made a single last try:

Deactivate “PressAndHoldEnabled” in the GUI of System-Settings>“Input-Help” (then choose keyboard, and uncheck the checkbox at the bottom)

bildschirmfoto 2017-01-03 um 14 39 03

I also used

$ defaults read -g InitialKeyRepeat 15 $ defaults read -g KeyRepeat 1

Those 2 adjustments only worked after disabling the checkbox in my first step.

This seems to work for me sort of as fast as in El Capitan:

defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 15

Can’t make it go any faster than this unfortunately.

To be clear:

  • the UI sliders within System Preferences > Keyboard do not reflect changes made to defaults (or at least do not update if the value is outside a particular range). Previously, setting keyrepeat 0 and initialkeyrepeat 10 would min/max the sliders.
  • Setting KeyRepeat to a float or zero value actually disables key repeat (e.g. holding a hey does nothing). So seems like 1 is the best we can do for now.

Leaving an update here. Using macOS Sierra 10.12.5 and it seems like defaults write -g KeyRepeat -int 0 + logout + login now works, albeit too fast.

The scales have changed drastically, as @hkdobrev has previously stated. I’ve documented this behavior here:

keyrepeat

Take note that while the GIF is indeed skipping frames, it really does skip some frames until I stop holding the repeating key. It’s that fast. The terminal frame skips seem to happen, but they’re more evident in my older MacBook, which means this is probably just dependent on how much text the terminal can handle given the limited resources of the laptop.

This behavior “works” on both my 11-inch Mac Book Air (2014) and my 13-inch Mac Book Air (2017). I’ve since set it to 1, but it 2 can be comfortable as well since the new 1 might be a little bit too fast for some people.

Doesn’t seem anyone mentioned this yet, but when doing defaults write -g KeyRepeat -int N and N is 0 or 1, then the slider in System Preferences shows up in the middle, but the actual tested key repeat is indeed blazing fast. And I got that working after just a Log Out, which is faster than a full reboot, so if you are like me and wanted to test different values out, you don’t have to wait for a full reboot.

@lobster-jack Thanks! I haven’t been able to confirm this myself yet (since everything is already working on my end), but here’s some more info:

in the GUI of System-Settings>“Input-Help”

For those running macOS in English, that’s System PreferencesAccessibility.

(then choose keyboard, and uncheck the checkbox at the bottom)

This is the checkbox that says “Enable Slow Keys”.

I can’t find any command that works for macOS Sierra. Something must have changed …

On macOS build 16a294a, after setting values through the prefs panel (and verifying that it works in the terminal), these are the values I see:

% defaults read NSGlobalDomain ApplePressAndHoldEnabled
0
% defaults read NSGlobalDomain KeyRepeat
6
% defaults read NSGlobalDomain InitialKeyRepeat
25

It works for me: sudo defaults write NSGlobalDomain KeyRepeat -float 0.000000000001

W/o sudo it does not work

…and suddenly - the error disappeared. I think I interpreted an answer in this thread wrong and made an incorrect assumption. Thanks, and sorry 😃

Good but I hate rebooting.

Guys it works pretty awesome and it will be much to fast (at least for me (; ), I was not even able to type. How I got it working (also in iTerm), the min. value for KeyRepeat seems to be 1 and for InitialKeyRepeat 15 (for fast repeat) via System Preferences, by using the following values:

defaults write NSGlobalDomain KeyRepeat -int 1
defaults write NSGlobalDomain InitialKeyRepeat -int 10

after it I closed all applications and explicit called the “Logout”. Maybe you should also try to keep the System Preferences closed or at least not pointing to the keyboard configuration.

PS: I guess that float values are also working since the KeyRepeat value could be set on previous Mac OS X versions to float value.

@knpwrs I’m experiencing the same thing. They key repeat set from CLI appears to have no affect. Furthermore, after a reboot, the settings set from the GUI are lost, which means I need to set the preferences every time.