43 comments

[ 2.7 ms ] story [ 78.4 ms ] thread
Should have 2019 in the title.
I'm doing the same things with Autohotkey but in a much less convoluted way.
I'd love to know how to get AutoHotkey running on my Macs!
I use Karabiner to make one specific change to my keyboard. I remap §/±, the top left key on my UK 2018 MacBook Pro, to escape. Massive quality of life improvement over the "soft key" escape on the Touch Bar.

I really should explore its other uses.

(I'm not actually against the Touch Bar. I find it useful for a few things such a screen shots. But escape should never have been on it)

You could assign escape to capslock in the MacOS keyboard settings.

Update: for simple keyboard remapping there is built-in `hidutil` command

https://developer.apple.com/library/archive/technotes/tn2450...

https://hidutil-generator.netlify.app/

Thanks for the tip.

The generator doesn't make it clear which key is "§" on a uk keyboard. From a quick Google it's listed as "none_us_backslash".

I believe that Karabiner uses the same name for it.
> For example, a common mod that a lot of programmers like to do is remap their Caps Lock key -> Escape. So if I tap the Caps Lock key, it instead emulates hitting the Escape key. You can do this pretty easily with Karabiner

Of course you can do this with stock macOS too.

System Prefs > Keyboard > Keyboard > Modifier Keys... > Apple Internal Keyboard + Caps Lock Key

I use Karabiner to map CAPS to ESC on single tap, but it's mapped to CTRL when I hold it. It's really great to have a CTRL button on the home row.
I do that too, and even map hold on enter to ctrl too
Karabiner is a bloatware. I've spent some time to uninstall it completely.

For a simple keyboard remapping I use built-in 'hidutil' command. https://developer.apple.com/library/archive/technotes/tn2450...

There is also https://hidutil-generator.netlify.app/

TIL about 'hidutil', do you know if it can remap single key to a combination of keys? E.g: remap Caps Lock to "Ctrl + Option + CMD"
I'm not aware of such feature but I've found that there are other properties in hidutil configuration

https://github.com/FSecureLABS/OSXFuzz/blob/600f28c1c4a1211c....

    "HIDKind",
    "HIDInterfaceID",
    "HIDSubinterfaceID",
    "HIDOriginalSubinterfaceID",
    "HIDParameters",
    "HIDVirtualDevice",
    "HIDKeyRepeat",
    "HIDInitialKeyMapping",
    "HIDKeyMapping",
    "HIDResetKeyboard",
    "HIDKeyboardModifierMappingPairs",
    "HIDKeyboardModifierMappingSrc",
    "HIDKeyboardModifierMappingDst",
    "HIDKeyboardCapsLockDoesLock",
    "HIDKeyboardSupportsF12Eject",
    "HIDKeyboardSupportedModifers",
    "HIDPointerResolution",
    "HIDPointerResetPointer",
    "HIDPointerConvertAbsolute",
    "HIDPointerContactToMove",
    "HIDPointerPressureToClick",
    "HIDPointerButtonMode",
    "HIDPointerButtonCount",
    "HIDPointerAcceleration",
    "HIDPointerAccelerationSettings",
    "HIDPointerAccelerationTable",
    "HIDScrollReset",
    "HIDScrollResolution",
    "HIDScrollReportRate",
    "HIDScrollAcceleration",
    "HIDScrollAccelerationType",
    "HIDScrollAccelerationTable",
    "HIDScrollResolutionX",
    "HIDScrollResolutionY",
    "HIDScrollResolutionZ",
    "HIDScrollAccelerationTableX",
    "HIDScrollAccelerationTableY",
    "HIDScrollAccelerationTableZ",
    "HIDScrollMouseButton",
    "HIDScrollZoomModiferMask",
    "HIDTrackpadAcceleration",
    "HIDMouseAcceleration",
    "HIDClickTime",
    "HIDClickSpace",
    "HIDWaitCursorFrameInterval",
    "HIDAutoDimThreshold",
    "HIDAutoDimState",
    "HIDAutoDimTime",
    "HIDIdleTime",
    "HIDBrightness",
    "HIDAutoDimBrightness",
    "HIDFkeyMode",
    "HIDStickyKeysDisabled",
    "HIDStickyKeysOn",
    "HIDStickyKeysShiftToggles",
    "HIDMouseKeysOptionToggles",
    "HIDSlowKeysDelay",
    "HIDF12EjectDelay",
    "HIDMouseKeysOn",
    "HIDUseKeyswitch",
    "HIDDisallowRemappingOfPrimaryClick",
    "HIDMouseKeysEnablesVirtualNumPad",
    "HIDResetLEDs",
    "HIDAccelCurves",
    "HIDTrackingAccelCurves",
    "HIDScrollAccelCurves",
    "HIDAccellCurvesDebug",
    "HIDScrollAccelCurvesDebug",
    "HIDAccelGainLinear",
    "HIDAccelGainParabolic",
    "HIDAccelGainCubic",
    "HIDAccelGainQuartic",
    "HIDAccelTangentSpeedLinear",
    "HIDAccelTangentSpeedParabolicRoot",
    "HIDAccelTangestSpeedCubicRoot",
    "HIDAccelTangentSpeedQuarticRoot",
    "HIDAccelIndex",
    "HIDScrollCountMaxTimeDeltaBetween",
    "HIDScrollCountMaxTimeDeltaToSustain",
    "HIDScrollCountMinDeltaToSustain",
    "HIDScrollCountIgnoreMomentumScrolls",
    "HIDScrollCountMouseCanReset",
    "HIDScrollCountMax",
    "HIDScrollCountAccelerationFactor",
    "HIDScrollCountZero",
    "HIDScrollCountBootDefault",
    "HIDScrollCountReset",
Is it possible to remove caps lock delay with this? I used built in remapper on Mac os to remap caps to esc and there was this massive delay. Unusable for vim. But with karabiner it prompts and removes the delay.

Edit: can perhaps use https://github.com/gkpln3/CapsLockNoDelay

I use caps to escape too but I don't see any delay. I don't use vim BTW.
Incredible that I'm only learning about hidutil today... thank you.

To your knowledge, is there any cli way to assign key combinations to menu items as seen in system preferences -> keyboard shortcuts?

While I understand it might be overengineering for your use cases, it isn't bloatware.

Karabiner can do more than simple 1:1 key remapping. For example, my capslock key is now a hyperkey when pressed and ⌘T when tapped. If that is possible w/ hidutil, please let me know and I stand corrected.

Let's get off the "I don't have a use for it, so it's useless/bad" train, please.

I use Karabiner Elements to:

1. Map my Caps Lock key to be an Escape key when I tap it and a Control key when I hold it down.

2. Map my Shift keys to be left and right parenthesis when I tap them and Shift keys when I hold them down.

3. Map the Tab Key to be a Tab key when I tap it and an ALT key when I hold it down.

I also set my keyboard to Dvorak.

These modifications make it much nicer to work with Emacs and VS Code with Emacs bindings.

Karabiner is almost too flexible. It let's you do almost anything, but it's so hard to configure it correctly.

I use it for example to remap CAPS -> CTRL and CAPS + ' = `. Sometimes it just enables caps lock instead.

Also, after few hours of use laptop starts to feel as if it's lagging. 1 key press will output multiple letters. The only solution is to restart karabiner every few hours.

Anybody has any simple alternatives? Even if it costs a bit of money.

I can recommend kmonad for the same use cases full-heartedly. With Linux, Windows, Mac support and nice docs.

https://github.com/kmonad/kmonad

So this replaces setxkbmap, xmodmap, and xcape?
Yes. Plus you get layers and other more advanced features in the style of qmk.
One nice feature of Karabiner is that mappings can be device-specific. I’ve mapped my presentation clicker’s Up and Down keys to the PgUp and PgDown needed by something I use.
After some time using Karabiner (still use it), I moved most of the remappings to skhd[0]. I find karabiner a bit too complex for just remapping a few combinations. The main reason I keep karabiner is because it lets you have a different behavior on key-tap vs. key-hold, and to remap Caps Lock to a combination of keys, i.e: map Caps Lock to "Ctrl + Option + CMD" instead of just a 1:1 mapping.

[0]: https://github.com/koekeishiya/skhd

Can Karabiner use fn as a modifier key? fn+sth would be optimal additional shortcut layer
Why not use QMK [1]? Both of the author's keyboards (Anne Pro 2 and a TADA68) support QMK, there's a lot more to do with QMK, and it's on the keyboard itself.

[1]: https://qmk.fm/

QMK is not great, honestly, IMO. It’s very constrained in what it can do, especially without having to recompile, and a lot of it depends on your keyboard.
I am using Karabiner so that my modifier keys (shift/ctrl/alt/cmd) are global instead of per-keyboard, so that the modifiers on my main keyboard also affect my Keybow 2040 function pad. I would love to know of a simpler way to do it.
I was also using Karabiner to launch/switch apps instantly but I got tired of editing large configs to add/remap keys to apps.

Eventually I wrote rcmd (https://lowtechguys.com/rcmd) to streamline this workflow of switching/launching an app by the first letter of its name.

It will dynamically map Right Command + first letter of app name to already running apps, and you can map your own letters by just pressing Right Command + Right Option + letter to assign.

I eventually replaced everything I was using Karabiner for with specialized apps like rcmd, HyperKey (https://hyperkey.app/) and skhd (https://github.com/koekeishiya/skhd).

I'm still missing the left/right Shift press once for parentheses, but I can live without it.

It’s cool when the mapping is one to one.

Once it’s one to many it’s a nightmare. You have to write scripts in a complicated format (full time professional programmer here) and they don’t even give you the facility to edit these scripts from within the app.

https://karabiner-elements.pqrs.org/docs/json/external-json-...

Why is it more complex to configure than an IDE? I don’t get it.

You don't even need it for one to one mappings. hidutil is built-in with MacOS https://developer.apple.com/library/archive/technotes/tn2450...
Or, maybe, don't use a 60%. How is tapping [ then ] to generate { a time-saver? Just seems like micro-optimization for very little gain.

I use an 80% because I don't actually need the numpad (I can type at full speed using the number row instead of reaching over for the numpad).

Using the arrow key without looking is simple because it's the only thing on the corner and I can return to the homerow easily without looking as well. It's faster for me to reach to it than to remap it to a Capslock (remapped to some other key) plus hjkl.

Instead I'm a gamer, so I set Capslock to activate an extra layer and use WASD for the arrow set so I have a set of arrow keys for either hand.

I like my Fn keys in groups of 4 across the top so I can easily reach for the correct one without looking.

Just uninstalled it. For some fancy keyboard like kinesis freestyle, it is not applicable. For some modern keyboard that supports VIA, its feature is under par and is useless.