dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Key repeat broken in macOS Sierra

Open jdsimcoe opened this issue 8 years ago • 65 comments

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.

jdsimcoe avatar Jul 14 '16 17:07 jdsimcoe

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.

hkdobrev avatar Jul 14 '16 17:07 hkdobrev

Tried doing this:

defaults write NSGlobalDomain KeyRepeat -int 1

And here's what I get:

2016-07-14 13:51:07.168 defaults[8647:1323339] Could not write domain Apple Global Domain; exiting

jdsimcoe avatar Jul 14 '16 20:07 jdsimcoe

Use diff to compare before and after the changes (quickly). I can't imagine Apple changed this to no longer use NSUserDefaults. Maybe it's not in NSGlobalDomain anymore.

Tatsh avatar Jul 15 '16 01:07 Tatsh

@hkdobrev If it was just a matter of forbidden value, replacing -int 0 with -float 0.001 would have done the trick and been a better way than -int 1 [except if -float was forbidden too]. ;)

ktgvv avatar Aug 01 '16 19:08 ktgvv

@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

mathiasbynens avatar Aug 01 '16 21:08 mathiasbynens

@mathiasbynens That didn't seem to work.

jdsimcoe avatar Aug 01 '16 21:08 jdsimcoe

@jdsimcoe It does for me on OS X El Capitan 10.11.6 (15G31) when rebooting afterwards.

mathiasbynens avatar Aug 01 '16 21:08 mathiasbynens

@mathiasbynens I'm on macOS Sierra and that setting has changed or something because neither works at all... they must have changed the value.

jdsimcoe avatar Aug 01 '16 21:08 jdsimcoe

@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.

mathiasbynens avatar Aug 01 '16 21:08 mathiasbynens

when I do this defaults read NSGlobalDomain KeyRepeat... I get 1e-12. When I do defaults read-type NSGlobalDomain KeyRepeat I get Type is float.

jdsimcoe avatar Aug 01 '16 21:08 jdsimcoe

When I change it in the Preferences slider to the fastest value I do defaults read NSGlobalDomain KeyRepeat and get 2. And the type is integer.

jdsimcoe avatar Aug 01 '16 21:08 jdsimcoe

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

jdsimcoe avatar Aug 01 '16 21:08 jdsimcoe

I tried to take a wild guess, I don't have any Mac running macOS Sierra DP. If I get what @mathiasbynens and you @jdsimcoe say, my trick works for OS X 10.11.6 El Capitan but not macOS 10.12 DP4 Sierra. Maybe it actually is a matter of forbidden values. If -int works, -float maybe works too. Have you tried to defaults read NSGlobalDomain KeyRepeat with the slider put at different random values [not just the extremes and middle but some points here and there on the slider as well]? Right now, the question I'm asking myself is: did Apple reverse how it works [eg a bigger value means a higher rate] or just lock the values to a certain range [eg between 1 and 3]?, and if they did, does setting the slider's cursor to a point somewhere changes from an integer to a floating-point number [eg the extremes and middle at 1, 2 and 3, and the values between as 1.n and 2.n]? What bugs me is that either the slider is locked to a range of integers such as one integer by stopping point [which would explain why floating-point numbers don't work], the slider is locked to a range of integers by can accept floating-point numbers within that range or something escapes me.

ktgvv avatar Aug 05 '16 21:08 ktgvv

Im on DP 5 and cannot seem to get the float to increase to speeds I was experiencing prior. also, you may need to tweak the InitialKeyRepeat value if you're getting no key repeat at all.

wprater avatar Aug 16 '16 16:08 wprater

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

mickeys avatar Aug 18 '16 19:08 mickeys

@wprater InitialKeyRepeat's value is actually the time it takes for key repeat to initialize, that is how long you have to stay pressing the key before it automatically repeats. Maybe it needs to be set to a shorter value along KeyRepeat in macOS Sierra?

Also, I highly discommend setting InitialKeyRepeat lower than [ 7 ; 10 ]: hardly will you press a key that 2 or 3 characters will have been input; on my 2013 MacBook Pro, I can set it to 5 but I need to keep it around 10 on my 2010 MacBook. See my .osxmavericks for more.

ktgvv avatar Aug 19 '16 18:08 ktgvv

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

anhkind avatar Sep 21 '16 11:09 anhkind

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.

knpwrs avatar Sep 21 '16 12:09 knpwrs

@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.

danemacmillan avatar Sep 21 '16 14:09 danemacmillan

For keyboards and mouse fine-tuning I'm exploring the use of https://pqrs.org/osx/karabiner/ . Only thing is a rewrite of the app is in progress for macOS Sierra support at: https://github.com/tekezo/Karabiner-Elements

kdeldycke avatar Sep 21 '16 15:09 kdeldycke

@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.

jdsimcoe avatar Sep 21 '16 15:09 jdsimcoe

For me:

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

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

nuc avatar Sep 21 '16 18:09 nuc

This is sad, I really liked having blazing fast key repeat. Has anyone found anything faster than

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

?

blakeperdue avatar Sep 21 '16 23:09 blakeperdue

Nothing i've tried has been as fast as keyrepeat 1 and initialkeyrepeat 10 =/ I miss lightning fast, but I imagine i'll get used to this speed shortly.

rjorgenson avatar Sep 22 '16 01:09 rjorgenson

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

nuc avatar Sep 22 '16 05:09 nuc

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

daz avatar Sep 22 '16 09:09 daz

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.

blaedj avatar Sep 22 '16 12:09 blaedj

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.

kirbysayshi avatar Sep 22 '16 15:09 kirbysayshi

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.

ezintz avatar Sep 22 '16 21:09 ezintz

Regarding settings not being applied, I proposed some days ago to kill any instance of System Preferences to keep it from interfering. My PR is ready to merge at: https://github.com/mathiasbynens/dotfiles/pull/706

kdeldycke avatar Sep 23 '16 11:09 kdeldycke