Keyboard misbehavior triggered by...?

I’ve hesitated bring this here for several days, but frankly, I’m suddenly plagued with a keyboard problem. Let me be clear about a couple of things: first, this only started recently (and it’s intermittent) and second, I’m not laying this at KM’s doorstep.

I’m looking for debugging suggestions.

About a week ago, right after triggering a KM shortcut (control-option-command-1) to type my full name (something I’ve done a zillion times over the years without an issue) my keyboard began acting as if the control-key was permanently down. Typing any key, became typing control-key. Weird and dangerous.

I plugged and unplugged the keyboard; plugged it into different hubs, or straight in. I turned off all software inits; turned off KM and started it over again; rebooted the machine; exported all my macros, deleted all traces of KM entirely, and reinstalled.

Of all those things, only rebooting worked… and then it would pop up again, suddenly. Sometimes it was as if the control key was always down, and sometime other modifiers, such as shift-lock, command or option.

One thing I think I noticed (sorry, but it’s not 100% repeatable) was that they keyboard would go into “weird mode” right after using a control-option-command macro.

And about 1/2 the time, repeating the control-option-command macro immediately would clear the error, and cause the issue to go away (for a while, at least).

Needless to say, this greatly interrupts my day, and needs to be resolved somehow.

I just now changed the control-option-command to control-shift in all my macros (although that will take some getting used to…)

And I have a sneaking suspicion that this -may- h ave something to do with the setting of the keyboard modifier keys in system prefs. I’m using a PC-style keyboard, so I have those set to swap the command & option keys.

Again, this has worked fine for years, but I did discover by looking at the keyboard viewer, that the swap would not operate correctly. That is, I’d make the swap, but keyboard viewer would show the physical key pressed, not the swapped keys (as it should).

At some point I got that working again, but that’s disconcerting, and makes me wonder if the file that tracks/records that swap for the OS got corrupted.

So, I’d make some changes and use Find Any File to look for files changed in the past minute… only to discover that there are always hundreds of them. The names are often cryptic, and even the file path is not of much help.

If anyone knows which file it is, I’d love to toss it out and see if that fixes it.

But if even that fails to work, has anyone got any suggestions (that I have not tried already, please) as to what might be going on?

I know how hard these things are to debug, so no worries.

Honestly, this sounds like a mechanical issue with your keyboard. I know you see different results after you reboot, but I still think it’s probably a mechanical issue.

Try a different keyboard.

1 Like

That was also my first thought. If nothing else, it will eliminate one possible cause.

One other thought: Make sure the keyboard is very clean. Vacuum it, and hold it upside down and tap strongly one back. Over the years I have seen incredible stuff fall out of users keyboards.

Thanks, folks. Sorry I left that off, but swapping keyboards was about the third thing I tried. It’s a software issue of some kind, because once the issue arose, swapping in a different keyboard made no difference.

I should have mentioned that.

Oh… and I couldn’t figure out how the command-option-control key combination would cause the shift key or caps-lock to become “stuck” on…

The modifier keys are stored here:

~/Library/Preferences/ByHost/.GlobalPreferences.<UID here>.plist

In the file search for modifiermapping and you’ll find entries like this:

  <key>com.apple.keyboard.modifiermapping.1452-542-0</key>
  <array>
    <dict>
      <key>HIDKeyboardModifierMappingDst</key>
      <integer>2</integer>
      <key>HIDKeyboardModifierMappingSrc</key>
      <integer>0</integer>
    </dict>
  </array>

There are several entries of this type and it is not very transparent to which key and to which keyboard they belong. But by changing the settings while observing the changes in the file you can find it out.

Since you are considering to remove this file (not sure if this is a good idea), keep in mind that the OS uses some kind of preferences caching. That is, deleting a prefs file often has no effect. Some say it helps to kill the cfprefsd process. Alternatively you can use the app Prefs Editor.

-excellent- advice Tom. Thank you ! :slight_smile:

Tracy
www.valleau.gallery

PS:

I found a post on stackoverflow where somebody claims to have a clue of what the numbers mean. He says:

0 seems to be the Caps Lock key, 2 and 10 seem to be left and right CTRL, 3 and 11 seem to be left and right Option, and 4 and 12 seem to be left and right Command.


But, since you have a problem with stuck modifiers, I can’t really imagine that it has anything to do with this prefs file.

You don’t have, by chance, any macro/script that could be triggered accidentally (or by another macro) and that contains something like this:

tell application "System Events"
	key down control
	key down option
end tell

I sometimes ended up with fatally stuck keys while playing around with lines like these :wink:

Edit: Note: Do not run this script!

1 Like

First, thanks for your efforts on my behalf, Tom. Greatly appreciated.

No: I don’t have any such self-created macros.

In the interim here, I’ve been purging system caches and other "shotgun"
approaches, including a safe boot. Now I’ll have to wait and see if the
problem manifests again.

Meanwhile I’ll look at that .plist file (I have plist editor) and see if
anything looks corrupt, or unusual. After I look at the whole thing, I
might consider whether it’s safe to take such a list from another Mac,
and replace it. If there is a bunch os machine-specific stuff, however,
I’ll skip it.

Again: thanks.

Tracy
www.valleau.gallery

Hey Tracy,

You’ve fired up a test-user and tried a bare Keyboard Maestro set-up?

If that works properly it proves something has gone to hell in your current user.

-Chris

FYI: For effectively editing the file a generic ‘plist editor’ probably won’t work, due to the mentioned preferences caching. For an explication go to the site of Prefs Editor and scroll down to “Background Information”.

I have had a couple people report that after installing 10.11.6, after triggering a hot key macro the modifiers become stuck down. Since there are thousands of people using Keyboard Maestro on 10.11.6, it seems likely there is some other factor involved in the cause of this. One suggestion is possibly the Wacom driver software. Other than that I haven’t got any other possible conflict/culprits.

Well, to round it out, here’s what I did: I viewed the plist using Pathfinder on my (troubled) machine and on my MacBook. Pathfinder will show a file’s contents without having to specifically open it, and keep the contents ‘live.’ Keeping that screen open, I could see what happened when I used system prefs to change the modifier keys.

When the keys -are- modified, here’s what (part of) the plist looks like:

“com.apple.keyboard.modifiermapping.1452-594-0” = (
{
HIDKeyboardModifierMappingDst = 4;
HIDKeyboardModifierMappingSrc = 3;
},
{
HIDKeyboardModifierMappingDst = 12;
HIDKeyboardModifierMappingSrc = 11;
},
{
HIDKeyboardModifierMappingDst = 3;
HIDKeyboardModifierMappingSrc = 4;
},
{
HIDKeyboardModifierMappingDst = 11;
HIDKeyboardModifierMappingSrc = 12;
}
);

When the modifiers are reset to system default, that entire entry is missing.

I do not understand why there are two pairs of entries, nor why only one pair is reversed. Interestingly if I go thru the modified/not modified sequence a few times, which pair is modified flips between the first pair and the second pair.

Modified on:
3/4 11/12 4/3 12/11 (2nd pair reversed)
Modified off
(Default = no entry)
Modified on:
4/3 12/11 3/4 11/12 (1st pair reversed)
Modified off
(Default = no entry)
Modified on:
3/4 11/12 4/3 12/11 (2nd pair reversed)

I don’t understand that either, but it appears to be the same behaviour on each mac.

What I did was first check the file in PathFinder using my MacBook (not a PC keyboard, of course), to see how a pristine file behaved, and then went back to this machine (which has the PC keyboard, and the new issues) and observed it behaving just the same as the MacBook.

So… there’s a long description of why my suspicion was wrong, and it’s not a corrupt file.

Something else is going on.

Unless you folks have “an AHA! moment” don’t spend any more time on this. I’ve cleared a bunch of caches, and I’ll hope that fixes it. If things run as normal, I ought to run across it sometime tomorrow. If I can make it thru Monday without an issue, I’ll tend to believe it was something cured by my roto-Rootering…

I’ll let you know… and, again, my thanks for your courtesy.

Tracy
www.valleau.gallery

Thanks, Peter. (posted my “round it out” reply before seeing yours).
Actually, in a weird way, it’s nice to know that it’s "not just me."
I did upgrade to 10.11.6 and I do have a Wacom Cintiq.

Well: this is going to be fun…

Tracy,
I would assume you’ve tried these but I am throwing them out there just in case.
Have you tried:

Resetting NVRAM
Resetting Power Manager (I didn’t see if you indicated it was a laptop or desktop/workstation)
Reset to default System Preferences/Keyboard/ each Tabs “restore defaults”, (lower right corner in each tab)
Checked System Preferences/Accessibility for status of sticky keys checkbox and slow keys checkbox
You mentioned a wacom, have you tried removing it and testing.
Removing and re-installing the wacom driver or updating it.

Run a scan with Malwarebytes (free) https://www.malwarebytes.com/antimalware/mac/

I also installed the 10.11.6 update. I have two strange things that have happened since, one with Voice Control and the other when I installed a System Prefs pane specifically MercuryMover after which the System Prefs panel window distorted and the text and graphics got jumbled and I couldn’t do anything. I was able to restart the computer and removed the panel. Chris stone said he was still using it without issues so I attribute my problem to a corrupt download or bad file.

I had an issue a while back which was kind of funny but the control key got stuck and I couldn’t do anything. I had forgotten that I had a second keyboard attached. There was something pressing the control key on the second keyboard. That’s why I was leaning towards the wacom. Maybe something is stuck there or a setting in the panel gliched?

Consider cables and hubs that may be plugged in too.

Thanks. All rational suggestions, to be sure. (I’ve spent 38 years with Apple products, and am a certified consultant, so most of those were done, as you suggested.) The problem is that there is no specific trigger, so it’s very hard to test.

The issue is that I had pretty much the same setup for months, even years, and didn’t get the issue until installing 10.11.6. I changed all my command-option-control macro triggers (to shift-control) and changed out one USB 3 hub for a USB 2, and have not experienced the issue at all today.

One thing that you hinted at, but is an other “gotcha” is a blu-tooth trackpad having something on it.

It’s frustrating as a retired programmer to have not figured out what exactly was causing the problem, but right now, I’m just glad I got a whole day without troubles.

Thanks again for the suggestions.

Hey, welcome to one retired programmer from another!

We’ll keep our fingers crossed for you.

Well, it came back, but (knock on wood) I -think- I found a way to make it repeat: use command-option-control and a number key (certainly 1 or -). Further, it appears to be a toggle, so that if the keystroke is repeated immediately, the “lock on” (of some modifier key) is reverted.

I mention this because Peter has seen this report from a few other folks, and I thought it might help.

(My email is down right now, so it may take me some time to be aware of any replies…)

Thanks again, everyone.

Hey Tracy,

Could you possibly be activating Sticky Keys?

-Chris

I could not duplicate it using Command-Control-Option-1 as a trigger to type my name.

What exactly is the macro? Does it reliably cause the problem? Do you still have the Wacom driver installed? Is it possible to uninstall it to test to see if the issue remains?

From Peter:

What exactly is the macro?
using command-option-control 1 type "Tracy Valleau" (w/o quotes)
no other triggers

Does it reliably cause the problem?
no

Do you still have the Wacom driver installed? Is it possible to
uninstall it to test to see if the issue remains?
see below

______________________________________

[OK: when I used my command-option-control macro to -type- the line
above, just now, as I was replying in MailMate, the keyboard went wonky.
I switched to photoshop and back, and the problem went away. This sent
me off on a new set of tests. See below ***]

OK... this is as convoluted as I'd expected.

(First, my apolgies, as my email has been down for FIVE days, and only
got fixed last night.)

Removing on any lengthy basis, the Cintiq from my system is not an
option, since I use it to make a living. Yes: equally, I use KM and my
coputer to make a living too, so it's a "rock and a hard place" issue
for me.

Nonetheless, I removed the Wacom driver easily because today Wacom
released a new driver. While it was not installed, I tested, and did not
get the issue... at least during -that- period of time. but... that
doesn't really mean much because my previous take that I could repeat it
at will, was premature, and ultimately wrong, and the problem -is-
intermittent.

So, I reinstalled the Wacom driver, and rebooted. (Unfortunately, to do
the new install required that I lose all my table and pen settings, so I
took some time to remember and replace them again. I'm not willing to do
that again, but if I can removed the driver and still keep my settings,
I'll continue to test.)

My test has been with BBEdit, to see if the keyboard is working
properly.

I can repeatedly use command-option-control 1 to type my name, and
-most- of the time, nothing goes wrong. But when it does (and it has,
seemingly at random) the result is not consistent either. Sometimes it
will lock the keyboard into uppercase; sometime it will lock down the
option key; sometimes it's simply impossible to tell what's happening
because only one or two keys respond at all.

Sometimes immediately typing the macro again reverts the problem
(usually when it's a uppercase error) but that fails of course when the
keyboard goes into never-never land.

*** (new tests) And when that (never-never land) happened just now, I
switched from BBEdit to Photoshop (which was open already) and clicked
to select the canvas, and then switched back to BBEdit, and everything
was fine again.

Then, I decided to change the operation of the macro from type to paste.
There is a difference: type will eventually cause the issue, while
preliminary tests indicated that paste does not.

in fact, you might want to try this:

create a command-option-control - (dash) macro that -types- this:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

(that's 189 a's and a CR embedded at the end of the string)

I've tried that in BBEdit and TextEdit, and do not get consistent
results. Sometime I'll get a few å instead of a; sometimes the line
breaks in the middle; sometimes the cursor ends up within the line.
(This is with the Wacom driver still installed.) If random characters
are getting mixed into the typed text, that might be the cause of this.
That is, perhaps during the typing, something is injecting into the
stream KM is putting out.

This behavior seems to be easily repeatable. Doing about 10 or so of
these "long a" macros in a row reveals the inconsistency in both BBEdit
and Text Edit, at least as things are set up on my machine now.

So: here's the summary -

The results with typing and pasting text are different.

It appears that something is corrupting the typed stream, while paste is
unaffected.

with Wacom driver, the situation continues and is intermittent
without it needs more testing.

At least once, changing the focus (switching apps) restored normal use.
(From a debugging perspective, this is a nice tidbit of info.)

Intermittently, repeating the macro restores normal use.

The problem seems to be limited to command-option-control, at least
since I have not been able to reproduce it using the same macros
converted to control-shift.

I'm confident that the problem is not inherent to BBEdit, since The
first time I noticed this was filling in a web form in Chrome, and the
keyboard started misbehaving in there. Switching to BBEdit was a debug
tool, so see what was happening.

Things for me to try:

  1. see if I can remove the Wacom drive without having to spend an hour
    reinstalling its controls.

  2. see if setting up a "no actions" for the general "all apps" controls
    of Wacom is possible and works.

  3. see if I can trigger the problem with other macro modifier keys. (ie,
    is it just one control, option, command that is triggering it, or is it
    that specific combination?)

  4. as a retired programmer, I know how long trying to whittle this down
    can take (days, literally) and I need to decide how much time I can take
    away from my business and family to devote to it. Some to be sure;
    enough, however, is another question.

1 Like