I'm all about being more productive as a developer, so I'm trying to force myself to spend less time moving my right hand from my keyboard to my mouse and back. I've been spending time thinking about how to comfortably become more keyboard-centric. I'm no expert at this, but I figured it's worth sharing my journey thus far.
I work on a Mac (MBP at work, iMac at home), and therefore this post will be about some of the tricks I've discovered that are making my life a little easier (and keeping my hands on the keyboard).
I don't have much need for my Caps Lock key. I really only use it when I'm writing comments in an angry tone (to remind myself to fix/add something when I get the chance). But, the Caps Lock key is so conveniently located next to my left pinky (which, by the way, isn't super nimble). It'd be nice if I could use that Caps Lock key for something useful... And it turns out, macOS actually allows you to re-bind your Caps Lock key to any of the other modifier keys (Control, Option, Command). Here's how:
- Open System Preferences.
- Click "Keyboard".
- Find the "Modifier Keys..." button at the bottom right and click it.
- Select your keyboard (if necessary), then from the "Caps Lock Key:" dropdown, change it out to whatever you please. I'm using Option/Alt, since there doesn't seem to be a lot of system-level hotkeys that use Option.
- Voila! Now pressing Caps Lock doesn't actually lock you into capital letters, it has the functionality of the Option key.
Here's a screenshot:
MacOS's Mission Control is pretty nice (I think, anyways). It can be nice to have multiple desktops and easily navigate between them. By default, I believe macOS will bind Ctrl + → to "Move right a space", Ctrl + ← to "Move left a space", and so on. That's not a bad default, but I want to be using my new Caps Lock key, since it's easier for my clumsy left pinky to hit that than the Control key. So, I went ahead and changed some Mission Control shortcuts. Here's how:
- Open System Preferences and then click "Keyboard".
- Click on the "Shortcuts" tab, which allows you to modify a handful of keyboard shortcuts available by default.
- Select "Mission Control" from the left-side, and from there you can begin changing the shortcuts. I re-bound the following:
- Set "Mission Control" to Option + I.
- Set "Application windows" to Option + K.
- Set "Move left a space" to Option + J.
- Set "Move right a space" to Option + L.
- I chose those bindings so I can use my left pinky to trigger Option, then keep my right hand on the home-row and control Mission Control. This allows me to quickly navigate back and forth between desktops.
Here's a screenshot of my configuration:
Shout out to Ali Spittel (can I @ people?) and her recent post, clueing me into Spectacle. I was using BetterSnapTool before, but that's not a free app and had more features than I needed. Check Spectacle out here. Spectacle basically allows you to easily snap a window to a certain portion of your screen. So you can quickly snap a window to the left half, or the right half, or fullscreen, etc.. Once you get used to using a tool like this, there's really no going back. Try using it for awhile and then using a Mac without it installed... It's painful.
Once Spectacle gets installed, you'll have to give the app permissions on your Mac. Once that was finished, I opened it up and cleared out all of the shortcuts. I want to keep using my Caps Lock key! So, (amongst others) I set the following:
- "Center" to Option + ↓.
- "Fullscreen" to Option + ↑.
- "Left Half" to Option + ←.
- "Right Half" to Option + →.
Here's a screenshot of my settings:
These allow me to use Caps Lock and my arrow keys to snap my windows into different positions. This is particularly helpful on a larger screen where you want to windows side-by-side (say, VSCode next to Chrome) while filling as much space as possible. The follow GIF shows this in action - I'm just holding Caps Lock and pressing different arrow keys!
Alfred is a Spotlight replacement tool that does so much more. The free version allows you to do Spotlight-like things (and some other things), and is quite great. I definitely recommend you replace Spotlight with it right now.
Alfred also has a paid extension pack called the "Powerpack" which costs about 19 Euros (about 22 USD). I'm all about my free software (ballin' on a budget), but if I'm going to spend any money on software - it's going to be on the Alfred Powerpack. There are so many cool things you can do with it, but I'll just showcase one cool thing related to this post.
Once you install Alfred, you can choose what hotkey you want to open the Alfred search bar. I'm using Option + A so that I can do Caps Lock + A to quickly open that without moving my fingers from the home-row.
Now, for the rest of this section I'm going to be talking about a feature -- "Workflows" -- that is only available in the Powerpack. If you've got the Powerpack, you can create custom "Workflows" using Alfred. These can consist of various actions triggered in various ways. We can use this functionality to add additional hotkeys! I found that I like binding hotkeys to certain apps, so that I can open an app using a quick hotkey. Mac's Application Switcher (via Command + Tab) is nice, but I don't feel super quick with it when I'm managing 4 or 5 applications.
With Alfred, I like to bind hotkeys to apps in a way that's really easy for me to remember. Here are some examples that I have set up:
- Have Option + C (which is also now Caps Lock + C) open VSCode. In my mind, "C" stands for "Code".
- Have Option + W open Chrome. In my mind, "W" stands for "Web browser".
- Have Option + T open Terminal. Again, "T" for "Terminal".
- Have Option + M open Spotify. "M" for "Music".
To do this, open up Alfred's settings/preferences window (you can search "Alfred" from the Alfred spotlight search) and go to the "Workflows" tab (again, assuming you have the Powerpack). Here's how we'll set up Option + C to open VSCode:
- At the bottom of the left panel, there's a little + button. Click on that to create a new Workflow, and select "Blank Workflow". Fill in a name for the Workflow. This will then give you a blank canvas.
- Right-click in the blank canvas and you'll get a dropdown. Select "Triggers > Hotkey".
- Once you select "Hotkey", it'll ask you which Hotkey you'd like to select. I chose Option + C, and you can actually press Caps Lock + C here. Click save once you've selected your hotkey.
- Now, right-click on the canvas again and select "Actions > Launch Apps / Files". This will open a dialog for you to "drop a program into". To do this, I triggered Alfred, searched for VSCode - and once I found it, just dragged it from Alfred into the dialog. Press "Save" when you're done.
- Now, we just need to link our trigger to our action. Hover your mouse over the Hotkey trigger element on the canvas. It should highlight the element and show a little "knob" on one of its sides. Click and hold on that and start dragging it toward the action. You should be able to connect these two things.
And there you go! Now hitting Caps Lock + C will open up VSCode! Once you've set some of these up, you can start switching between applications easily without having to take your hands off the keyboard!
I'm finding this quite useful when I want to work on a laptop and still have my applications fullscreen. I can toggle between Chrome, VSCode, my terminal, my MongoDB GUI, etc. really quickly!
I'm new to the "no-mouse gang" and I'd love to hear some suggestions from others! [Vim bindings in VSCode...? Cool hotkeys in Chrome? Other stuff?]