I've started[1] to do similar things on macOS using Hammerspoon[2]. So far I've set it up to let me:
1. Use shift when pasting something to simulate typing in the text instead, getting around websites that block pasting.
2. Use ";" as a hyper key. By holding it down and pressing another key, I can switch between specific programs without cycling. I can also use hjkl as arrow keys.
3. Automatically switch audio input and output devices according to my specified priority order. Because macOS would frequently get it wrong, including treating my monitor as a speaker for some reason (it doesn't have built-in speakers).
4. Make control act as escape when tapped. I use this in conjunction with remapping caps lock to control in macOS system preferences. I previously used Karabiner Elements for making caps lock work as escape when tapped and control when held, but I was able to uninstall Karabiner because Hammerspoon was sufficient.
5. Disable the insert key because I've never wanted its functionality, but I would sometimes hit it accidentally.
Having used both Hammerspoon and AHK, the latter is somehow both terser and more ergonomic. I miss it dearly when I'm not on Windows.
And I actually use caps lock as a "fn" key for hjkl/arrows. Who needs caps lock, really?
I've actually gone kind of crazy with this idea and made my left ctrl, shift and alt behave as fn+ctrl, fn+shift and fn+alt, so that e.g. left ctrl+h actually does ctrl+left. Then I made fn+[ = pgup, fn+] = pgdn, fn+; = home, fn+' = end and fn+\ = delete, with the same augmented fn+LHS modifiers.
Took me about a week for the muscle memory to catch up and allow me to correctly hit ctrl+L with the right hand when I want to go to the address bar, but now I'm ridiculously fast moving around in Excel without having to touch the arrow keys.
Only downside is I have a relatively problematic left wrist and this set up added to the already LHS stress to the already very imbalanced qwerty layout, so it forced me off mechanical keyboards to a low profile logitech right around the time COVID-19 hit.
For Excel on Microsoft Windows, there is vim_ahk [1] to add Vim key bindings (after adding EXCEL.EXE to VimGroup) using AutoHotKey.
For LibreOffice, especially its spreadsheet calculator Calc, there is the vibreoffice [2] extension.
You can use Quick Actions (formerly Services) to trigger Mac automations, with customized Keyboard Shortcuts and text input replacements but it’s all scattered across a dozen apps and it’s kind of clunky to piece a workflow together from all these parts. But if you know the ins and outs, there’s a lot you can accomplish from a Mac, particularly as macOS has historically had better app support for AppleScript and somewhat better accessibility tooling. http://www.macosxautomation.com/automator/services/extension...
Recent attempts to lock down the system point to how it’s “not the default” to customize your Mac outside the App Store. And I find the share sheet is still more useful on iOS than on macOS (for now?) just as Finder is more useful on macOS than Files app is on iOS.
That said, Windows Terminal and WSL highlight that Microsoft isn’t slowing down here and Apple might actually need to play catch-up at some point and evaluate new approaches to developer and power user pain points. (AppleCare-supported upgradable storage is on my wish list but that’s not technically the software’s fault... just a policy Apple used to have and then later removed from their website as they moved to proprietary SSD controllers)
> And I actually use caps lock as a "fn" key for hjkl/arrows. Who needs caps lock, really?
Caps Lock is quite useful, because it's the perfect location for remapping the Ctrl- and ESC-Keys. Which is no surprise, as they originally where located there.
Under linux there is a nice tool for overloading keys, so they behave one way when pressed short, and another way when holded longer. With programmable keyboards you even have it OS-independant.
I use https://github.com/alols/xcape for some while now. It's old, reliable and straight forward, just does it's job. Only downside is that it seems to be limted to X11. Not sure how well it will play with wayland.
There are now also some alternative tools, with more ability, which allow overloading just on the side. I have them on my list for a while now, but not done much yet with them.
> including treating my monitor as a speaker for some reason (it doesn't have built-in speakers).
This is quite common on HDMI monitors. Since the HDMI connection transmits both audio and video, the monitor just accepts both audio and video input. They would then have a 3.5-mm jack to allow you plug in an actual speaker or headphone to receive the audio output.
Which is something I don't understand, just separate the signal and give me a digital output from the monitor, why are monitors doing digital analog conversion for audio too, all of a sudden?
It was useful for me when I hooked my nephew's Nintendo Switch up to my computer monitor to let him play and then connected desktop speakers straight to the monitor.
There are usually different flavors of the same base-model. Some have speakers, other not. Not adding speakers, but leaving the rest ist just cheaper and more reliable than tinkering with every flavor for single features.
The usage of ; as a hyper key is fascinating. This is the first time I've seen someone do something with Hammerspoon that's actually tempting me to try it out.
For paste blockers I've been using an Alfred workflow that types keys using AppleScript. It doesn't work with characters that require special input like ü, which is annoying, but it's sufficient for passwords. The benefit here is I'm not using up a global hotkey for such an infrequent use-case (especially not one actually used by other apps, such as Terminal.app).
Using ; as a hyper key blew my mind, like the article recently about how a certain developer calls all of his scripts ',something' so if he want to run a cli command of his, pressing comma then tab will show only his scripts, so ',py(tab)' won't have 15 pythons in it.
I had almost used up all combinations of Ctrl, Alt, Shift, Win and letters at one point, and still never thought of making my own hyper key. It's genius.
At my new job I'm afraid to download AHK at all :(
Man as someone who has been putting off the upgrade that's too bad, I figured their solution of creating kind of a virtual keyboard input would be pretty solid going forward.
Does Hammerspoon work just as well? Karabiner is so incredibly solid.
Hammerspoon is doing the stuff talked about here using event taps. I don't know if you can reliably use event taps to simulate different modifiers though, or to prevent a modifier from actually taking effect (e.g. if you wanted to remap one modifier to another).
I'm hoping Karabiner Elements figures out some solution going forward. It still works on Catalina but the expectation is the "legacy kext" will no longer function on 10.16.
Why macos doesn't offer something like this by default is beyond me.
Really, there are some really smart people at apple. You know some of them have customized their environment. You know apple has internal tools.
Why don't they get it and support customization of their os?
They're also not very supportive of "outside" tools. Say you want to use python on macos. Apple has only the most passing support for it. Same with bash or anything else that could put up a dialog box or whatever without having to compile/use xcode/other barrier to entry.
applescript doesn't count.
I know you can add software like macports or homebrew, but I mean first class support from apple.
This one really drives me mad. Is there really any legit reason to this?
By the way my hack is I paste it in the address bar, then just drag-drop into the field. Works 50% of the time or more (fails when a lot of these stupid websites don't use placeholder attribute but rather use some sort of Javascript for the placeholder text)
> This one really drives me mad. Is there really any legit reason to this?
No. Which is why I set the about:config option "dom.event.clipboardevents.enabled" in Firefox to false. That turns off the ability of websites to block pasting in Firefox.
Oooh, neat! Thanks! I presume it would also defeat those idiotic "let's insert a backlink or an ad into the text you just copied" scripts.
Truly, there are very few legitimate reasons for a site to even know you've copied or pasted something. Makes me think this setting should be a whitelist.
When I had a work-Mac I used Keyboard Maestro for stuff similar to this. It can do stuff based on a variety of input events; I had it do "location-y" stuff for me upon wake so it would do different things based on if it woke at the office or at my house, for example.
> 2. Use ";" as a hyper key. By holding it down and pressing another key, I can switch between specific programs without cycling. I can also use hjkl as arrow keys.
Did you overload the ;-key, meaning it sends ; when pressed fast, and acts as modifier when hold and pressed with other keys? Is'nt that kidna painful to use and inflicts false input occasionaly?
I too have some personal modifier-keys. I remaped Pause-key to the Right alt-key, and use for persional settings in apps. And I remapped the left Alt-key to F22, and use it for window managing and staring/raising apps.
Benefit with this is that both keys are exclusively used by me and the pause-key is also available even when my setting is not available.
That's correct, but I've never gotten false input before. If my setup gave me false input even 0.5% of the time, I wouldn't use it at all. I give myself 250 milliseconds to release the ; key to type it as normal, and that has worked fine for me, both on my laptop keyboard and on my external keyboard.
I find it very easy to use since my pinky finger sits on the ; key by default.
Although really intreaged to finally find some really good use for Hyperspoon something in that script didn't work.
pressing ; and releasing it kept the hyper active so if you pressed some trigger key it triggered it instead of doing the input. Also pressing ; repeated did of course nothing.
Wished there would be a better way to actually map hyper key that only is activated if pressed down. Well, I went back to BTT and setup fn + and this works too.
I happily used Karabiner for years but only to handle my caps lock remapping. It's not bad. I just generally like having as few dependencies as possible. I definitely needed Hammerspoon for other stuff, so if it can cover my one use case for Karabiner as well, then I only need to use one program instead of two.
One specific reason I want to go with Hammerspoon in the long run for key remapping is that I plan to do more complicated things, like setting up key layers. And even if that's possible with Karabiner, I'd rather maintain the complexity with Lua code rather than Karabiner's JSON configuration, which is complicated enough that someone created a separate tool[1] just to generate the configuration.
I should note that one of the maintainers of Hammerspoon specifically recommended[2] using Karabiner instead of Hammerspoon for key remapping because Karabiner was built to do that. Hammerspoon has a much higher level view of key events, from what I understand. I don't plan to do any remapping with modifier keys though. I plan to only use the letter keys for everything. Something like: press and hold ;, then press and hold v, and then tap a. And that will re-arrange my current windows into my preferred arrangement. Stuff like that. Based on my initial experience, I should be able to do everything with just Hammerspoon.
1. Use shift when pasting something to simulate typing in the text instead, getting around websites that block pasting.
2. Use ";" as a hyper key. By holding it down and pressing another key, I can switch between specific programs without cycling. I can also use hjkl as arrow keys.
3. Automatically switch audio input and output devices according to my specified priority order. Because macOS would frequently get it wrong, including treating my monitor as a speaker for some reason (it doesn't have built-in speakers).
4. Make control act as escape when tapped. I use this in conjunction with remapping caps lock to control in macOS system preferences. I previously used Karabiner Elements for making caps lock work as escape when tapped and control when held, but I was able to uninstall Karabiner because Hammerspoon was sufficient.
5. Disable the insert key because I've never wanted its functionality, but I would sometimes hit it accidentally.
[1]: https://github.com/dguo/dotfiles/blob/master/programs/hammer...
[2]: https://www.hammerspoon.org/