7 ms·
Mac Keyboard with Hidutil
- rgoulter 4y agoIf you do desire "external keyboards, more than one, slightly different configurations for each one", ... then at that point I think it would be worth considering the benefits of a keyboard where the keyboard firmware itself can be customised. With the customisable keyboard firmware, your tweaks would remain on the keyboard, & wouldn't need any setup on the OS.
- kitsunesoba 4y agoConfig being saved in firmware I think is probably the most underrated boon of enthusiast keyboards. No shaky hacks or badly written background daemons, just plug it in anywhere there’s USB and the board acts as expected.
- IggleSniggle 4y agoThe downside of this approach is that you can’t easily do “one size fits all, inclusive of built-in laptop keyboard” mods. Since my configuration files follow me from computer to computer anyway, it’s easier to just manage all the mods in one place and rely on the daemon. If I was doing support though, I would definitely go the firmware route.
- kitsunesoba 4y agoYeah that's fair, and not all daemons are equal — something like Karabiner for instance is manageable, but the software required for the various functions on big name (e.g. Logitech) peripherals can be downright horrendous.
- amitp 4y agoAgreed. I do have that, but I also want to use the same keyboard with Mac, Linux, Windows. So far I've been switching keyboard configurations on the keyboard every time I use a different OS, but I'd like to move that to the OS so that it's automatic.
- ink_13 4y agoInteresting, but if I'm understanding this correctly, this can only do straight remaps. I'll stick with Karabiner Elements for its ability to make a key do one thing when tapped (e.g., send a keystroke like ESC) and a different thing when held (e.g., act as a modifier like CTRL).
- bt1a 4y agoYeah, Karabiner seems to be unmatched in terms of customization for power users. The main problem with straight key remapping is that you have to deal with the application layer having different keybindings for the same actions, even when you have the appropriate keys swapped. Same for navigating the OS if you're interested in duplicating Windows navigation functions in Mac ( Command+E to open Finder, Command+S for Spotlight Search, Ctrl+Shft+Esc to open Activity Monitor ) I spent a long time creating a giant karabiner config file for myself, but recently an MDM update at my work broke the virtual keyboard driver that Karabiner requires. I haven't figured out a way to install it. I may have to go begging to IT.
- SSLy 4y agoDo you think I can get something like this for windows or libinput/wayland?
- goosedragons 4y agoKmonad or keyd. Keyd is Linux only but Kmonad is cross platform but harder to configure IMO. Both work everywhere in Linux including TTYs.
- csdvrx 4y agoDo either handle the modifier bits when you remap? So that they are not set unless you want to?
- psd1 4y agoPowerToys for Windows has a keyboard remapper. It has nowhere near the power of karabiner, but otoh you don't have to wade through karabiner's config file.
- mproud 4y agoNot to be confused with `hdiutil`.
- fabiospampinato 4y agoI wish you could get an Hyper key with built-in utilities without needing to install anything else. Unfortunately hidutil can't map multiple keys to a single key.
- nammi 4y agoI think Karabiner(-Elements) is way more popular and probably more flexible, but I've had a lot of success with Ukelele for 6-7 years. I exported one layout and just copy it to each new macbook. Specifically it lets me set `option` as a dead key so I can have `opt+i`, `opt+j`, etc... shortcuts in editors. https://software.sil.org/ukelele/ https://software.sil.org/ukelele/
- ris58h 4y agoIt is more flexible but it's a bloatware. I had to spend some time to uninstall it completely. https://karabiner-elements.pqrs.org/docs/manual/operation/uninstall/ https://karabiner-elements.pqrs.org/docs/manual/operation/un...
- zeroalpha 4y ago> bloatware That word doesn't mean what you think it means. What those instructions explain is (1) removing macOS permissions, (2) removing logs/temporary files, (3) removing config. These are normal things that some may want to keep after uninstalling the program. Calling it bloatware is misleading and dilutes the meaning for things that are actually bloatware.
- kps 4y agoThe Mac keyboard layout system is good; it's basically a tree of states, so it's both simple and capable. Ukelele is a decent layout editor; the only down side I recall is that it's not easy to create chains analogous to X11 Compose. Editing or generating keyboard layout XML directly is also possible. Karabiner and hidutil are at a lower level; they modify the key codes that are the input to layout.
- vvladymyrov 4y agoHiduntil gets job done for remapping keys. The only downside for me is that configuration lost after keyboard was disconnected.
- amitp 4y agoI haven't tried this yet but the configuration on https://www.digihunch.com/2022/11/key-mapping-on-external-pc-keyboard-on-macbook/ https://www.digihunch.com/2022/11/key-mapping-on-external-pc... looks like it will run when the keyboard is connected.
- hacliff 4y agofor the colemak users http://homeowmorphism.com/2017/05/27/Remap-CapsLock-Backspace-Sierra http://homeowmorphism.com/2017/05/27/Remap-CapsLock-Backspac...
- BruceEel 4y agoYes, good stuff. Also useful if you have an external PC keyboard and want "INS(ERT)" (0x700000049) to do something sensible...
- ris58h 4y agoIt should have 2019 in the title.
- teekert 4y ago"On the laptop keyboard, some media keys should be function keys but other media keys should stay media keys. When using fn I want to get the other version of the key." Wow, this is exactly how it should be! Who cares about F1 and F2, let them be brightness controls! A button for "full screen" on F5? No thank you, that should always be "refresh". Btw, I switch a lot between MacOS and Linux, and my Logitech MX master can be Mac or Windows/Linux. It's maddening that the thing has a "super" and and "cmd" key. They should have been the same key. Alt and Opt should also have been the same.
- akira2501 4y agoMost laptops I've used have an "Fn Lock" key or mechanism. That's one of the first "out of the box" items I enable. If it lacked one, that'd be a "back in the box" experience for me.
- teekert 4y agoSure, but it does not let you combine brightness controls with F5. It’s either or, the functions or the F keys. This let’s you mix.
- alana314 4y agoI map my right option key to ctrl, because I use ctrl + arrows way more than option
- ivan888 4y agoI wrote a pretty simple wrapper around this that gives the keys easy names and can store the configuration in a human readable format: https://github.com/ivangreene/keymap https://github.com/ivangreene/keymap Was unaware of the --matching option at the time, could be an interesting extension but I personally have no need for it
- amitp 4y agoThank you! That looks great.
- karmakaze 4y agoI have a script I use with Starcraft2 (on Mac I should know better..) hidutil property --set '{ "UserKeyMapping": [{ "HIDKeyboardModifierMappingSrc": 0x70000002B, "HIDKeyboardModifierMappingDst": 0x7000000E1 }, { "HIDKeyboardModifierMappingSrc": 0x700000039, "HIDKeyboardModifierMappingDst": 0x70000002B }, { "HIDKeyboardModifierMappingSrc": 0x7000000E1, "HIDKeyboardModifierMappingDst": 0x7000000E2 }] }' It remaps tab->L.shift, capslock->tab, L.shift->L.alt Why? Using TheCoreLite, so I can hit tab/caps/shift labelled keys with pinky and cmd with thumb and reach a good number of hotkeys including function keys. On Windows, the PowerToys keyboard manager can do the same with a nice config UI.
- pixelbath 4y agoOh, man, thanks for this. I've been lamenting that Cmd is essentially dead without remapping it, and this is the last blocker for me adopting TheCore.
- csdvrx 4y agoOn Windows, you use AHK to do that and way more. You know about Caps being Esc alone and Control when chorded? Likewise, AHK can turn the Alt keys in Home/End when pressed alone, and the Shift keys in PageUp/PageDown. One handed Alt-PageUp on the left hand side of the keyboard becomes pressing and holding the left Alt then pressing and releasing the left Shift.
- rxhanson 4y agoI just happened to make a post about this today, too, in the form of a quick tutorial with Automator to turn the hidutil commands into an app that can be configured in launch on login system settings, if desired: https://medium.com/ryan-hanson/key-remapping-built-into-macos-c7953b1a62e4 https://medium.com/ryan-hanson/key-remapping-built-into-maco...
- dhosek 4y agoThe first comment on the post includes the comment: “Also, how lost are you when you use someone else's laptop or keyboard and it doesn't act like yours?” which is a big part of the reason I don’t do fancy stuff remapping keyboards and the like. The only real customization I do is to turn off caps lock because only psychopaths leave caps lock enabled.¹ ⸻ 1. From which we can deduce that the person who set the default for the caps lock key being enabled is a psychopath.
- h4x354x0r 4y agoHi, I'm able to successfully do key remappings with a com.local.KeyRemapping.plist file in the LaunchAgents folder. But I want to do a "one-to-many" remap, not just a 1-1 remap. I.E remap "a" to "abc". Is there a way to do that? I haven't stumbled across a way to output a string of characters in the "HIDKeyboardModifierMappingDst": construct. Is there a way to do that? Thanks,
- h4x354x0r 4y agoOK, I finally figured out how to do this with Better Touch Tool. At first I couldn't get it to work, it was passing the original keystroke through and then trying to delete it, which doesn't work in all apps I need. What I was doing wrong in BetterTouchTool: I was using the "Keyboard Sequences" instead of the "Keyboard Shortcuts" construct in the configuration editor. The "Keyboard Shortcuts" in BetterTouchTool does exactly what I want. I blame COVID brain fog on struggling with this for so long.