Ask HN: Does anyone use keyboard/mouse extra buttons for coding?
Usually gaming mice have a few extra buttons that can be mapped and some gaming keyboards have extra keys for mapping/chaining functions to them in games. Of course there is also the world of people that build custom keyboards. Has anyone used these extra buttons/keys for programming uses? Is it helpful and what are the details?
159 comments
[ 4.6 ms ] story [ 226 ms ] threadI don't do it every day, but creating a macro can help a lot in that situation.
I have a lot of Razer gear and also a few pieces of Cooler Master gear.
The real frustrations I have though involve disabling or changing buttons in deeper ways. For instance, I love the alacritty terminal, but it uses ctrl+shift+c and ctrl+shift+v to cut-and-paste. One of those buttons opens the dev tools on my browser, which I could tolerate if it didn't also scroll the browser to the top, losing my place. So disabling keys or remapping them in applications helps.
Another pet peeve is that I fat finger the "insert" button on a laptop keyboard about once per minute so it is a candidate for disabling. Tools from the likes of Razer and Cooler Master only work with their gear, even Alienware's tools only work on the extra buttons and not on your existing buttons. So you need something like
https://github.com/microsoft/PowerToys
As for the mouse the value of remapping buttons is more limited IMHO since the act of pressing a button will usually cause a little bit of motion and screw up the alignment of what you were doing.
It’s helpful because I don’t have to remember key combinations and it means much faster feedback (and fewer broken builds).
I have a macro for ctrl+shift+v on my Keyboard since it's the Evolution (Linux mail app) shortcut for moving emails. I also have macros for ctrl+alt+left and ctrl+alt+right to switch desktops more easily.
I have a vim macro "<leader>ji" that does "<esc>:e src/dir/i-always/go/to/prefix_" and "<leader>jv" that does "<esc>:e src/other/common/dir/filename_prefix_". Also "<leader>r" types "Reviewed-by: dyingkneepad <dyingkneepad@domain.invalid>".
I also sometimes think about implementing a keyboard macro that does a BnB combo in Skullgirls :). Maybe one day lol, but that's cheating and I wouldn't do it online (also I'd get screwed on whiff or block). Maybe I could use just Xautomation for that (that uses libXtest).
But the most useful of all, by far: alias s='cd ..'
> I also have macros for ctrl+alt+left and ctrl+alt+right to switch desktops more easily.
This is done by Super+h and Super+l over here. To bring the active window along with, add Ctrl...
I kept mistaking one of my shortcuts so I made the wrong version play a sound file of John Denver yodeling. It still gets me sometimes :-)
I must be getting old because I have no idea what you are saying.
I've been on a minimally mapped POK3R (60%) for years (pretty much CL=l2mod, l2mod+hjkl=arrows). It's been OK but still can't touch-type properly and even after years as daily driver still prefer low-profile laptop style keys.
Just switched this week to a self-built Lily58proc Choc[1] for better ergonomics and forcing myself to touch-type. My layout is still a work in progress, I still type very slowly, and would love to see other coders' mappings for inspiration :)
[0] https://gist.github.com/3nprob/41bfaca6dd712de673a140b2b3be3...
[1] https://github.com/kata0510/Lily58
Super handy.
https://brettterpstra.com/2016/09/29/a-better-hyper-key-hack...
I found another project, which also uses Karabiner Elements, to be a good starting point for customization. I especially like moving system-wide type shortcuts like 1password to it so I have fewer conflicts with editor plugin shortcuts.
https://github.com/Vonng/Capslock
Technically I used the logictech software to map those buttons to "ctrl+-" and "ctrl+shift+-" which are the keybindings for those actions.
----
1. Universal keyboard shortcuts
I was using an application called ControllerMate with my Microsoft Natural Ergonomic Keyboard 4000.
I set up a bunch of hotkeys and such, and basically used the software as a translation layer. My best example follows. When I pushed the 'calculator' button on the keyboard, it would check which application was running (Chrome, Safari, Firefox, Vivaldi, etc, or Visual Studio Code) and send the appropriate keyboard shortcut to it to open the JavaScript console (or the Terminal in VS Code). I might've even set it up to start an actual Terminal and switch to it if none of those applications were running.
Likewise, I had a button to go directly to Search in relevant applications, and used the 'Zoom' keys to zoom in or out (again, ControllerMate would intercept the special key, and then change it to the appropriate shortcut for the running application).
This was great. I gladly paid for it. It doesn't work with the most recent versions of macOS :-(
----
2. Switching between applications
I use an application called Contexts to let me switch between applications quickly. For example, I'll set one browser window up as being accessible using Command-1, and an editor window that can be brought up using Command-2.
I often have dozens of windows up, and when I start doing this, I'll usually use about four shortcuts for different applications, and it can be darn handy.
----
3. Window management
I use an application called BetterSnapTool. I've got it set up so that if I press the left Command key and a number or symbol on my numeric keypad, that it'll move and size windows. This lets me put two windows side-by-side almost instantly, for example, or, indeed, four windows in different quadrants of the screen, or one taking up one third of the display and another taking up two thirds.
(I am usually using multiple monitors, where this is less useful, but I do usually remember that I love it if I'm screen sharing and limited to one display).
2 are for copying and pasting, and 1 is for activating a programmable tooltip.
Here are the apps to achieve above (I built them):
1. Mouse config tool for Mac https://github.com/tanin47/noo
2. Programmable tooltip for Mac https://github.com/tanin47/tip
This makes me very productive mechanically.
Keyboard shortcut for typing, creating builds etc
It's a layout to avoid switching constantly from mouse to keyboard and remain most of the time with one hand on each devices.
What a tire fire of a UI on Reddit.
https://old.reddit.com/r/KeyboardLayouts/comments/kpklnq/my_...
But your point still stands.
1. I change platforms too frequently, so I cannot have a custom setup; and
2. when I try to run distributed with VNC or MSRemoteDesktop, there are too many conflicts when configuration, so it makes a mess.
If you only ever work on one computer, it is a great idea, but you will find it challenging to acclimate to another computer.
I have a layer for mouse movement with wasd. On the same layer, I've bound hjkl to the arrow keys, so I can get vimish movement wherever. Below these keys on the same layer I have some browser navigation shortcuts.
I use evil-mode in Emacs. The key below my left thumb is control on hold, escape on tap, and it works beautifully. On my left thumb cluster, I have a key that's option (meta in Emacs land) on hold, and option-x on tap (so I can easily hit M-x in Emacs).
On another layer I have hotkeys to manage window tiling. I use Magnet for macOS; works fine for my needs. One thing I wanted that Magnet didn't have was a half-width-but-centered hotkey; I was able to build that into a macro on my keyboard.
Keyboard macros are a beautiful thing. QMK firmware is the best!
My layout: https://configure.zsa.io/moonlander/layouts/xK7zR/latest/0
I have Cmd+Shift+R (Refresh) and Cmd+Alt+I (Dev tools) on the two big red keys. On my navigation layer I have distinct keys for emacs navigation: C-x [, C-x ] (page forward/backward) and ESC f, ESC b (word forward/backward).
And I have Ctrl+Cmd+Space (MacOS emoji picker) on a single key.
My layout: https://configure.zsa.io/moonlander/layouts/4DrXo/XxmmW/0
I have a programmable keyboard that I could use to achieve the same thing, but I really like having a dedicated device and find that I use it more than if it was just a function layer in QMK. IMO this is also one of the legit uses of individual key RGB on a keyboard beyond just bling-- you can color code keys.
The downside of this is that I oftentimes tap the side of the mouse when using a different computer (and realizing that there's no button to press) thanks to muscle memory.