2

Is it possible to disable a key in MacOs without installing a third party program (e.g. Karabiner)?

One of my keys is stuck and gets pressed continuously.

In Unix it is easy to do with xmodmap, is there an equivalent for mac.

Jdoe
  • 23
  • 1
  • 1
  • 3
  • The fn key on my PC keyboard wasn't working under macos. I tried assigning the control key to it in System Preferences, but no luck. I ended up just yanking the key out of the keyboard so I don't press it at all. – Michael Kelso Oct 04 '21 at 20:13

2 Answers2

1

Yes, but not easily

I'm still going to recommend you use Karabiner: it's easy, works well, and does exactly what you need to do. However, if you insist otherwise...

Unless your keyboard happens to be the Caps Lock, Control, Option, Command, or Function key, it cannot be easily remapped or disabled natively. Karabiner is your best bet.

If it is one of those keys, it can be disabled in System Preferences -> Keyboard -> Modifier Keys -> [The key you want] -> No Action.

enter image description here

However, if it's not, you'll have to create a custom keyboard layout. You can either do this by hand(ish), as suggested by Apple, or using a program called Ukelele. There's simplified instructions on apple.stackexchange.com, but I encourage you read the full documentation, it's not the easiest process. However, the main idea is you simply want to unlink the output of the keyboard, then save and install the layout.

enter image description here

JMY1000
  • 439
  • 2
  • 7
  • Unfortunately this is not working: https://support.apple.com/guide/mac-help/create-and-use-your-own-input-source-on-mac-mchlp2866/10.14/mac/10.14 I wanted to do it without a 3rd party cause I generally do not trust them security wise. – Jdoe Jan 18 '20 at 11:34
  • It appear though that Ukelele is to some extend more safe than the rest since it only asked for permissions for my Desktop folder, as opposed to Karabiner which asked permissions for every single key type in every single program. – Jdoe Jan 18 '20 at 11:43
  • @Jdoe That's a function of how each one works; Ukelele can only create a custom keyboard layout, while Karabiner can easily perform remapping on the fly. Personally I trust Karabiner—it's open source and well-reviewed—but if you don't, you're welcome to use Ukelele. – JMY1000 Jan 18 '20 at 17:36
0

Ukelele is essentially just a UI for OSX's .keylayout files, and you can manually edit them if you prefer. They're XML files and the schema is located at /System/Library/DTDs/KeyboardLayout.dtd

For example, this diff should change s to f:

-<key code="1" output="s"/>
+<key code="1" output="f"/>

You'll have to create a proper "bundle" folder in ~/Library/Keyboard Layouts, though, and it may be difficult to access the default layouts to get a sample to start from. You can find many custom ones on GitHub and other places online (example), so you could download one and modify it for your purposes.

Or if you want to compromise, you could use Ukelele to create a sample bundle based on your current layout, then uninstall it. At that point you can manually review the contents of the folder, manually modify it to fit your needs, and install it.

Ian Dunn
  • 282
  • 1
  • 5
  • 17