Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Faize

macrumors regular
Original poster
Sep 23, 2011
131
37
The longer you hold down a key for, the higher CPU usage gets - after 20 mins or so it uses up an entire core, and while I don't have the patience to do it for long enough to use up all cores, I have managed to get CPU usage up to ~400% just by continuing to hold down the key.

It's pretty obvious that macOS is somehow processing the increasingly long "word" on each keystroke, but what exactly is it doing?
 
  • Like
Reactions: Starfia and frou
The longer you hold down a key for, the higher CPU usage gets - after 20 mins or so it uses up an entire core, and while I don't have the patience to do it for long enough to use up all cores, I have managed to get CPU usage up to ~400% just by continuing to hold down the key.

It's pretty obvious that macOS is somehow processing the increasingly long "word" on each keystroke, but what exactly is it doing?
Might be the AI trying to match your 'word' with anything it 'knows'.
;JOOP!
 
  • Haha
Reactions: Ben Sparrow
The longer you hold down a key for, the higher CPU usage gets - after 20 mins or so it uses up an entire core, and while I don't have the patience to do it for long enough to use up all cores, I have managed to get CPU usage up to ~400% just by continuing to hold down the key.

It's pretty obvious that macOS is somehow processing the increasingly long "word" on each keystroke, but what exactly is it doing?
Specifically what process is utilizing up to ~400% CPU under this scenario? What is your Mac model and year? Bluetooth or wired keyboard? Etc.
 
That sounds like a fine observation – I've sensed intuitively that keystrokes come with processing on the Mac (and can guess this would relate to anything from layout to auto-correction or more), but I'd be curious about specifics too. I'm not sure what you're using, but for some time, for me, the general system behaviour when holding down a key is to open a contextual menu with variants of the pressed character, not to repeat the character; so I haven't yet found a way even to replicate this. So I'll ask too: which version of macOS, what settings, and which app?
 
We don't have a lot of details from the OP. I ran Activity Monitor on my M3 Max MBP with the window set to the CPU tab. On there, I held down the "J" key on the built-in MBP keyboard. The Activity Monitor process went from about 2-3% to 17% CPU and stayed there. Presumably because it was getting (and ignoring) the key events. But I didn't see any other processes use any more CPU time. As soon as I released the key, the CPU time for Activity Monitor went back to 2-3% No other changes in system CPU utilization. Maybe the OP is using BT or something. I'm using MacOS 15.5
 
the general system behaviour when holding down a key is to open a contextual menu with variants of the pressed character, not to repeat the character; so I haven't yet found a way even to replicate this
Same.
By the way, key repeat rate preference is to set to nearly the fastest with the delay set to about median. It is not set to off.

Performing Quality Assurance testing on macOS
The OP reminded me of when I worked in QA on software and we had to think of outside-the-box ways to uncover bugs.
In college, we were told when developing a UI/UX, to assume the user will try anything. Therefore, it was best if you had the widest range of testers, from the tech clueless to the well-versed criminal type with the bored, “What will happen…” or “Will it break…”, teenager in between.

Indeed, the most illogical (or manipulative) things:
why would you ever hold down a key for 20 minutes?
This sounds like something Homer Simpson would do to show as active on Teams as the nuclear power plant

Even with what you believe is the most succinct, simple, straightforward instructions and input options with every reasonable limit in place. In fact, this is why, despite it possibly requiring (far) more effort for you (i.e., the developer), having dropdown menus for every input that is definable (e.g., states, countries, number ranges, yes/no) is almost always a better approach.
 
  • Like
Reactions: frou
The longer you hold down a key for, the higher CPU usage gets - after 20 mins or so it uses up an entire core, and while I don't have the patience to do it for long enough to use up all cores, I have managed to get CPU usage up to ~400% just by continuing to hold down the key.

It's pretty obvious that macOS is somehow processing the increasingly long "word" on each keystroke, but what exactly is it doing?
The headline question is misleading. The real question relates to what happens while some key is stuck in the down position. And I would suggest that we should not really care.

My off the cuff guess is that the [very fast] OS just looks at each input device, including the [very very slow] keyboard every so often to check what may be going on with each relatively slow input device, the result goes to cache and that simply accrues CPU usage.
 
  • Like
Reactions: ignatius345
1751920901874.png

This you?
 
The headline question is misleading. The real question relates to what happens while some key is stuck in the down position. And I would suggest that we should not really care.

Care would be a strong word but I am now curious. Whatever combination of design decisions led to this it's an interesting result. Or an implementation bug.

One thing I've noticed from reading the blog, release notes, etc from the Asahni Linux people is that Apple (along with the rest of the industry I think) has been moving logic and therefore processing out of the devices on to the CPU. For example, getting microphone audio from Apple Silicon laptops requires processing Pulse Density Modulation data and beamforming the result whereas in the past this data would have been presented as Pulse Code Modulation from a USB standard device ready-to-go.

Perhaps in this case various keyboard handling logic that would have previously been handled on the keyboard, in the USB controller, etc now seems to be handled on the CPU.

Then while the result doesn't impact typical use (i.e. touchtyping text input for word processing, web, etc) I can now see how it impacts someone trying to use the keyboard as a controller (e.g. for games, controlling simulations, etc).
 
Then while the result doesn't impact typical use (i.e. touchtyping text input for word processing, web, etc) I can now see how it impacts someone trying to use the keyboard as a controller (e.g. for games, controlling simulations, etc).
... or someone who accidentally puts his/her bag on the corner of the keyboard and walks away ...
Here's such a someone. Pleased to meet you.
;JOOP!
 
Grab a sample in Activity Monitor (e.g. select the app you're testing, choose "Sample Process" from the View menu, then race back to the app and press/hold the key again). I tried this in TextEdit (CPU usage only went to ~6%) and the bulk of the activity was in spell checking.
 
  • Like
Reactions: MacCheetah3
Even with what you believe is the most succinct, simple, straightforward instructions and input options with every reasonable limit in place. In fact, this is why, despite it possibly requiring (far) more effort for you (i.e., the developer), having dropdown menus for every input that is definable (e.g., states, countries, number ranges, yes/no) is almost always a better approach.
 
macOS:
In that particular moment, I was reconfiguring the warp field parameters, analyzing the collected works of Charles Dickens, calculating the maximum pressure I could safely apply to your lips, considering a new food supplement for Spot...

OP:
I'm glad I was in there somewhere.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.