Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Tell HN: Have just discovered that I can use any key as Ctrl on my keyboard\
78 points by pfortuny on April 24, 2022 | hide | past | favorite | 96 comments
Sorry if this is silly but today I have discovered that my (pricey, I know) Ergodox-ez keyboard (but I assume any other "programmable" keyboard should work likewise) allows for any key to be programmed either for "press" or "hold".

And after more than a year using an uncomfortable configuration for my wrist (I use emacs a LOT), I have set 'j' to behave as CTRL when hold.

And then my mind has blown up.

No more weird thumb positions, or elongated pinkies.

I had done this with one of the large thumb keys for space when pressed, Meta when hold, but I had never imagined using 'j' (or, say 'f') for that.



As a software rather than keyboard hack, I've been using and loving the following setup on macOS: * Remap Caps Lock to Ctrl * Then use Hammerspoon[1] to map Ctrl(hold) / Esc (momentary press)

This essentially puts both Ctrl and Esc in a comfortable position on the home row, probably my favorite "ergo hack" ever.

[1] http://www.hammerspoon.org/


You can do the same with 1 config item using Karabiner-Elements also. Same exact thing just offering another option!


I do the same in the Ergodox QMK firmware, no app needed on the device. Just mentioning it since OP has the same keyboard!


> map Ctrl(hold) / Esc (momentary press)

Do you have an example of this configuration somewhere you could share? Or are you using something existing, like https://github.com/jasonrudolph/ControlEscape.spoon ?


am not OP, but I accomplish the same thing like this: https://github.com/kclejeune/system/blob/master/modules/home...

I previously used Karabiner for this and as far as I can tell, the behavior is the same.


I do the same with Karabiner, I didn’t realize Hammerspoon could handle that… might be able to drop one app from my “must have” list…


I always disable capslock - it's about the most useless key on the keyboard 99.9992% of the time


I have it set as a "super" modifier, i.e. cmd + ctrl + option + shift, perfect as then you can use it as a modifier for shortcuts as no programs use that a default keyboard shortcut


Take a look at the ultra compact layouts like Miryouku - it has six layers and home row modifiers (Shift, Ctrl, Alt, Super all as tap dance keys on home rows).

https://github.com/manna-harbour/miryoku

Before QMK, I used Kmonad and Keyd for getting these advanced features on any keyboard.

https://github.com/kmonad/kmonad

https://github.com/rvaiya/keyd


Kmonad is great! Much easier to configure than some of the standard Linux keyboard tools and can be reloaded quickly. I'd recommend it to anyone that wants to try out a new layout or do some fairly painless remapping.


Shall take a look, thanks!


Here's my setup on a standard Apple Magic Keyboard:

    caps lock  -> ctrl
    tilde      -> escape
    left ctrl  -> tilde
I borrowed this from the Happy Hacking Keyboard layout and haven't looked back since. I can now press escape with my left ring finger (right next to '1'), ctrl with my left pinky (right next to 'a'), and when I do need to type a tilde or backtick (not often) it's right under shift. On some keyboards I also map backslash to backspace and vice versa, to bring backspace closer. No more finger stretching!


That's where the ESC used to be on the MSX.. https://www.msx.org/wiki/images/6/6b/Nms8245a.jpg


I haven't used a Happy Hacking Keyboard, but why not left ctrl -> escape and tilde remains tilde? Perhaps it's just my hands but I feel reaching left ctrl is easier than reaching the tilde key, and I imagine hitting escape is more frequent than tilde (?)


Hmm, it's the opposite for me, somehow reaching my ring finger toward tilde just feels easier than curling my left pinky downward toward left ctrl. Plus my muscle memory is used to moving up and to the left to find escape.


I don't know about remapping ESC at all. You can get it by typing ^[ instead.


On a French keyboard, the 'tilde' key (left of the 1) is the symbol '²' which I hardly ever use. Therefore I remapped it to the € symbol using AHK. No more AltGr key combination to get it! (and I keep the '²' symbol with shift-'tilde')


I don't get it. There's already a ctrl on the left reachable with left pinky. What is missing is right-ctrl which you often need (tmux, vim, emacs...).


Similar to caps lock being ctrl when held and escape when tapped, I set up return to be ctrl when held and return when tapped. Nice keyboard symmetry this way too.


I'm using a very custom keyboard configuration and I'm doing all my config using Linux's xkb (X Keyboard Extension).

I'm for example using "modifier + ijkl" to send actual arrow key codes so I don't need to move to the arrows key cluster. It's not unlike gamers using wasd or esdf: ijkl mimics the arrows keys cluster. It just "makes sense". The modifier is always under my left thumb (I'm using a japanese keyboard, so the space bar is very narrow and I'm using the key at the left of the spacebar as the modifier for ijkl (and for other shortcuts). This is sweet because as actual arrows key code are sent, this works in every single program as if the arrow keys were actually pressed. I'm sure it can be even better: say by doing it at the keyboard controller level, bypassing the OS entirely but what I have works well enough for me.

Another trick: a modifier dedicated only to my window manager. Anything I need to do that is related to the WM gets done using a dedicated modifier. Never clashes with any single program. Bliss.

I do other cute things: OP mentioned using Emacs a lot... I configured things I use in Emacs all the time, like ivy / avy, to never require the pinkies (I removed the keys supposed to be pressed by pinkies from the list of available candidates).

Stuff like that. I spend countless hours on my keyboard setup and, to me, it's perfect. I did that years ago and since then I'm a happy camper.

> And then my mind has blown up.

Then I have one for you: you can use something else than ctrl to do ctrl-x in Emacs, using ctl-x-map. I'm using "key at the left of my tiny space bar + ." to do what ctrl-x does. No pinky and both hands are used (instead of doing left hand for ctrl and left hand for x).

> No more weird thumb positions, or elongated pinkies.

I don't really understand how you can get weird thumb positions on an ergodox though...


I use Dvorak and work on a diverse range of systems (rdp, Citrix, vms, etc). The biggest technical problem is random software not respecting your host OS key map. I also get bad knots in my back from unsplit keyboards.

Buying a dygma raise after two failed ergodox attempts (meaning my split keyboard attempts are probably close to $1500aud) was absolutely worth it. It solved both issues, the former by supporting programmability. I can also move the keyboard to random computers without issues.

Please consider buying a programmable keyboard instead of X11 hacks, i say this as someone who put up with the problems for a decade.


> Please consider buying a programmable keyboard instead of X11 hacks, i say this as someone who put up with the problems for a decade.

I know but... I'm using a HHKB Pro JP since forever: Topre is my "end game" switch. Some modded their HHKB Pro 2 with a programmable controller but I'm not sure the mod is compatible with an HHKB Pro JP. Sadly the whole custom keyboard community is basically 99.9% cherry switches, 0.1% other switches and 0% Topre so no luck for me there.

There are physical layouts that I do appreciate but zero switch that I like (I tried everything, from Model M s to ALPS to every Cherry color under the sun) besides Topre.

> Buying a dygma raise

I cannot type on a split keyboard that has the '6' on the left part. I don't care if the travel is shorter for the left hand: I actually learned touch-typing from a secretary and she taught me to type the '6' with the right hand. Decades ago. There's no going back ; )

Conceptually it also scratches me the wrong way that left index gets to hit 4,5 and 6 while right index only gets to hit 7. It feels just wrong : )


Sorry I literally meant consider, not ‘you must’ in a passive aggressive way :)

I’m surprised the HHB line aren’t fully programmable, and a quick google hasnt found any home-rolled firmware mods. Always wondered about usb middleware that remaps keys dynamically, but I’m glad you’ve thought about it!


Wow, thanks.

I am quite likely “holding it wrong” (TM) but I had to either extend my right hand too much to get to the ctrl key or was always oressing two keys at the same time.

It was probably a bad config but now… I’ve found it!


Here is a rundown of Linux key remapping software that I wrote a few months ago: https://medium.com/@canadaduane/key-remapping-in-linux-2021-...

My favorite is keyd, which allows the sort of hold vs press configuration spoken of.


This is pretty nifty, thank you. You are probably aware that you can do somehow advance remapping within Desktop Environment or Tiling manager level. KDE is decent. I mutilated i3wm config with Xbindkeys and Xmodmap. Keyd feels like a vastly more sane approach, not to mention the inevitable death of X.

Thank you for the write-up, you know you wrote that for just a handful of nerds with problems like this, happy to report you helped one!


Thanks. Someone else has suggested it too. I shall have to take a look for my work keyboard.


I'm going to be graduating from a twenty year affair with Microsoft Natural Ergonomic 4000s to a Keyboardio Model 100. I'm bookmarking all these interesting ideas for then! Currently I just have capslock remapped to ctrl, which is awesome.

However I also have a FS3-P USB Triple Foot Switch which is surprisingly handy. Cannot map a pedal as CTRL, as it is a separate keyboard device, but esc for Vim use, and ctrl-w have been useful common keys for me to be able to stomp on.

https://www.kickstarter.com/projects/keyboardio/model-100

https://duckduckgo.com/?kp=-1&kl=au-en&q=FS3-P+USB+Triple+Fo...


Is that because CTRL can only modify its own keyboard or something? I ran into something similar with my Ploopy Nano trackball. I wanted to do middle button scrolling but because it doesn't have any actual mouse buttons and I relies on keyboard keys for clicks I couldn't do it. I think in theory it's possible to make a virtual device in Linux using uinput and do it that way though.

The Kinesis Advantage also can have a foot pedal or foot pedals. It has to be specific ones though.


One of the first things I do on new computers is download a macro software (i.e AutoHotkey(1)) to remap troublesome keys on normal keyboards. The quick list I have going on this particular laptop: a) numlock always off(on?) b) remap right alt to be 'function' key for the f keys that double as volume up/down/mute c) remap '%' to be ctrl+`, as I use it quite often for autocomplete in a DB front-end

(1) https://www.autohotkey.com/


>download a macro software (i.e AutoHotkey(1)) to remap troublesome keys on normal keyboards

And, on Linux, this is combining `xdotool` with the native "shortcut" functionality in your desktop environment. ;)


Sxhkd and espanso together are closer to AutoHotKey, but still not comparable, unfortunately. Adding uinput to the mix gets closer (and in some ways further), but requires custom coding.


This is a great tip. I've had semicolon mapped to Ctrl when 'held' for the past year or two and it's worked well for me.

I don't have a fancy keyboard so I have to do it in software.

My AutoHotkey script for Windows (modification of something I found online): https://gist.github.com/zanemayo/f4ff05a83630b70ea32116e761c...

My Karabiner Elements config for Mac OS: https://gist.github.com/zanemayo/04690de0a6f9783dad5a98aad5b...


I became an unwilling victim of such feature in my Razer gaming keyboard.

One day a friends child was visiting and I put some games on for her. The little bastard somehow reprogrammed the 'r' key to empty macro, it took me weeks to find out what it was.


On a different programmable keyboard, with a more traditional staggered layout (the ErgoDox has a columnar layout where where keys are aligned horizontally) I used that same function but on Caps-Lock, left of A: press it combined with another key, it is CTRL; press it alone, it is ESC.

Programmable keyboards offer so many improvements, it’s incredible.

Some of that can be done with xinput on Linux, but as far as I know the different-key-when-held functionality is not available there. [Edit: yewenjie’s comment mentions keyd which apparently does have that feature! https://news.ycombinator.com/item?id=31146572] While I waited for this one to be delivered (was a crowdfunding campaign) I used that to simulate some of its features and surprised myself when I found out that I stopped using the dedicated cursor keys even if all my keyboards had them.

I had never thought of using J for CTRL. You lose the ability to enter Line Feed (Return) with CTRL+J which I do use from time to time, but it sounds intriguing. I might try it out one of these days.


You already mentioned Keyd but Kmonad also has that feature. Kmonad seems a bit more powerful but is a bit harder to configure than Keyd especially for something simple. Kmonad is also cross platform. The cool thing about them is that they work everywhere and not just in Wayland or X11 so it all just works in TTYs too.


I chose j just because I could.

Why do you lose ctrl-j? There is another ctrl on the left side of the keyboard. Uh?


> Why do you lose ctrl-j? There is another ctrl on the left side of the keyboard. Uh?

:-D Yes indeed, you are absolutely right. I had assumed that those keys would be used for something else but nothing stops you from having several CTRL keys.



I have a keyboard with GMK firmware. This is fairly easy to do. In combination with layers, my hands don't have to move around as much. Easier on the tendons and possibly faster.


THANKS!

I am going to try this with my kinesys at work. The ergodox I have is for home.


Most operating sytems allow remapping of keys, and at least for the common modifier keys (shift, ctrl, alt) make it pretty easy. You don't need an expensive programmable keyboard.

I remap caps-lock to ctrl on all my computers. Even my Chromebook allows this. Make Emacs much nicer to use.


Oh no, this is totally different (I also have an old kinesys at work and program caps etc. as I wish): here you can turn any other key into that… Even keys which are usually not part of a combination.

The fact that it is expensive has nothing to do with it (I bought it for my rsi).


Even for the tap-hold functionality, there is kmonad.

However, I think expensive keyboards (like the moonlander or the planck) are worth it for things like "symmetrical" and "thumb can use more keys than just the spacebar".


I use caps2esc [1] in Linux to remap capslock to ctrl on hold and esc on tap. It's such a simple yet insanely useful remapping! It really shines in modal editing (e.g. vim). I assume it's possible to use the underlying interception tools [2] to do that for any key without needing a particular programmable keyboard.

[1] https://gitlab.com/interception/linux/plugins/caps2esc

[2] https://gitlab.com/interception/linux/tools


Yes probably right.

But the ergodox has such a nice programming interface that it makes the OS-level configuration pale in comparison.


I searched for a way to do this on Mac and Windows as well. I’m going to give it a go.

[0] https://gist.github.com/ivyxjc/0ee9b1f37a5abdfbcd8f31db3c10f...


This is part of the fun of customizing a small keyboard. You experiment with different key layouts until you find the perfect one for you and learn it, making small adjustments along the way. I currently use a 36-key Draculad and the most fun customization was making Cmd+Tab ergonomic (there’s no physical Tab key).


Um, yes? It's one of their marketed features: https://ergodox-ez.com/#dualfunctionkeys

Much of the point of the Ergodox is that it's completely reprogrammable, and ZSA's Oryx makes that very easy for the Ergodox EZ and Moonlander (which I've just gotten). For other keyboards running QMK the QMK Configurator makes it relatively easy too, except for macros (I also have a Hotdox Ergodox). I use the keys my thumbs sit on as space on the left and enter on the right, and holding space as shift and holding enter as control. I use the two little finger home keys (A and I in the Workman layout) as letters when tapped and layer switchers when held. Left gets me symbols and numbers, and right gets me movement, editing, and more symbols.

You can also make keys act like modifiers are held down, e.g. a single key that does shift-enter for Jupyter notebooks, or ctrl-C, ctrl-V, etc. You could probably set up a whole Emacs layer or two like that. I also use autoshift, so a long tap on a letter key gives you the capital letter (this makes held letters as modifiers a bit less convenient).

With these keyboards I never move my right little finger to the right, as doing that on normal keyboards is really damaging my right wrist (hence spending hundreds of dollars on programmable keyboards with lots of thumb keys). I've been trying similar things in software for a while with AutoHotKey and sxhkd, but concluded I needed to do it at a lower level. UInput is an option for that on Linux, but programmable hardware is better I think (just expensive).

Since getting these keyboards one and two weeks ago I've modified the layout at least once a day on average, refining it further and further. Currently it's this: https://configure.zsa.io/moonlander/layouts/xDQXL/latest/0


Welll, that was $400 I didn't know I needed to spend. Looking forward to my moonlander arriving!


I'm gonna blow your mind now:

- You can have multiple layers

- You can choose "a" to act as your control key when held down, but create a "gaming" layer that disables this feature, so you'd have your "WASD" direction keys back for the game and hold them down to move around.

- You can have a mouse layer, which mean if you hold down a key, some other keys will control your cursor. I normally use this to scroll up/down (mouse scroll buttons) wherever page up/down keys don't work.

- You can add snippets and macros to some keys to automate something you type a lot (your email for example).

- You can configure the keyboard in a way that your finger don't need to travel more than one key away from the home row.


To OP and people who elaborately configure their keyboards - is it worth it? Does it improve performance by a meaningful amount?

I've been thinking about observing my typing / window interaction patterns and optimizing them, but never could find the motivation. Sometimes I catch myself pixel-hunting some control in my IDE and wondering if there is a shortcut for it, but then again, is configuring/learning the shortcut worth the trouble?

Or maybe configurability benefits kick in after a threshold? I think there is a reality where I can be at least 5% productive by just streamlining my "head-computer" link, but I'm not sure what it's going to take to get there.


Honestly, the biggest improvement for me has not been typing performance, but ergonomics. Being able to remap common shortcuts to things that don't stress my aging joints as much has been fantastic


Agreed, my motivation is bad joints, and performance and convenience are a bonus if they happen.


The biggest easy win for me has been to get a full-size standard layout keyboard and almost always use it with my laptop.


Has anyone made this easy to work with for non-Latin alphabets? I basically want the configurator tool to read an XKB layout and give me the labels I'd get when typing with those keycodes.

I've got myself Moonlander, and when I started to configure it, I realised that this is an uphill battle: I need to configure both base layer and the keyboard layout in software (there is no keycode for Cyrillic D or ZHE: so they've got some random keycodes for ASCII keyboards).

Add in any customisation I might want, and this turned into a full monthlong project.

So back to only Caps-as-ctrl for me for now.


Maybe interesting to know: You can use your left hand palm to press Ctrl and Meta.

Also see: https://mihaiolteanu.me/emacs-palm-press-the-ctrl-keys and http://xahlee.info/emacs/emacs/swap_CapsLock_Ctrl.html


I did this. Had holds on home row left hand do, ctrl,alt,shift and Function key and mirrored this with the right hand.

It became so natural that normal keyboards became hard to use.


Once upon a time, Apple shipped a keyboard with CTRL in the correct position!

The 'caps lock' and 'control' keys were swapped as compared to todays keyboards!


Back in the Apple II days. Caps Lock was actually a locking switch too, at least on my IIc. The Model F shipped with the IBM PC also had CTRL there. For some reason with the AT they decided to put CTRL in the corner and Caps Lock along home row.


I read the subject and thought "duh" but when I got to the content... I never would have thought of hold vs press. So obvious but so not obvious too.


Its all in the milliseconds, but I think Windows, Settings, Ease of Access, Keyboard offers more options even though its designed and intended for less able people to use, it has its own customisable potential most people overlook.


Exactly what happened to me this afternoon. There is no going back from this for me…


For those on Windows I have to plug [PowerToys](https://github.com/microsoft/PowerToys). In addition to the excellent "Video Conference Mute" it has the best key/shortcut remapper I've used on Windows. Fully open-source, but can be downloaded from the MS Store (gets auto-updated) too.

edit: fixed link


All: thanks for the great feedback.

I have also used all the linux/mac tools for other keyboards but honestly, everything pales in comparison with ergodox’s configuration tool and with being able to program ordinary keys and see it work BANG like that. I just wanted to share this because honestly it blew up my mind.


Interesting. Where did you move the J key? Was it hard to relearn typing prose with Js?


I think pressing J is unchanged, only when holding does it behave as ctrl. That's probably unnoticeable (as an emacs user and not a vim user :) ).


That means that 'j' is entered upon key release, while all other keys are activated upon key press. That slightly different behaviour on just one key would make me go crazy.


You could easily configure all of your keys to behave that way with no loss in functionality. The whole concept of "key press" versus "key hold" assumes that a "press" is released instantaneously.


No loss in functionality, but it adds tens of milliseconds of delay when typing.

Also, when using Emacs I often press and release the ctrl key without completing a control sequence, like when I'm thinking about scrolling but change my mind. I'd be splattering Js all through my source files.


I can't discern the difference between those tens of milliseconds of delay.

Worth considering the time (and effort) saved from moving the hands to the modifier keys. It's nice being able to have the hands remain on the home row.

EDIT: rather, there's hardly any speed lost (if any); but there's a big amount of comfort gained from using home row mods.

> Also, when using Emacs I often press and release the ctrl key without completing a control sequence

The behaviour is customisable, but e.g. if you're holding the tap-hold key for longer than a 'tap', then it'd still register as a 'hold' rather than sending a 'tap'.


> No loss in functionality, but it adds tens of milliseconds of delay when typing.

Well, no, it would add zero milliseconds -- and zero nanoseconds -- of delay. The difference between key press and key release does not affect typing at all. You're not waiting to see what happens after you press T before you go on to pressing I (or whatever letter you're following it with).


When I'm typing normally, keys are down for around 60 mS each. Having the software respond at the end of that 60 mS instead of the beginning adds about 60 mS of delay.


I disagree. Input-on-key-release feels very bad if you're used to it being on key press like all computers do. It feels like the keys are sticky and unresponsive. It's hard to explain unless you try it.


You only notice the difference when holding a key for auto repeat, which I almost never do, much less with alphabet keys.


You may also notice if you're typing a word; say 'jeans' and you press the e before you release the j. On a typewritter, you must release the first key before you press another, or you get a jam. On a computer, you don't usually have to, but with this configuration, it gets tricky. If j becomes control when held, you've got to start buffering key presses when j is pressed, and only once j is released (or held long enough) can you send the key presses on. I hope you're not playing a game which uses j, because your inputs now have jitter.


> but with this configuration, it gets tricky.

It may also be unclear what you intend if while holding 'j', you start pressing another key. The behaviour is customisable. https://docs.qmk.fm/#/tap_hold?id=tap-or-hold-decision-modes

> I hope you're not playing a game which uses j, because your inputs now have jitter.

Well, if you've got tap-hold on the keys "ASD", then games with WASD movement will be hard to play. :) -- I have a gaming layer without the tap-hold keys, separate from the normal typing layer.


No: you use j as always. Only if you hold it pressed, it becomes ctrl. Astounding.


Ergodox can map any key to whatever you want via modes, definitely recommend this as you'll end up with specific workflows mapped to their own modes. Its a little overwhelming at first but the learning curve is worth it imo.


For Windows: Re-arrange CAPS-LOCK, CTRL and ALT keys to their "original" positions. https://superuser.com/a/1264295


Or AHK.


Is there any applications for Linux which allow remapping keybindings on a per-application basis? I’d kill to remap chrome/FF keys, but afaict both browsers don’t allow this.


xkeysnail if you use Xorg. For Wayland, (sway) I applied a patch to make it work. If the window manager exposes the current focused window, then it's possible to make it work with xkeysnail.


Ta that looks like what I’m after!


This is baked into X11 with X resources files. Whether modern applications respect those settings is another matter.



Wow, so many ideas in a single photo. Thanks.


which keyboard do you use ?

https://gist.githubusercontent.com/sourcevault/f6623662bea27...

here is the code.


The MacBook Pro Touch Bar taught me to use caps lock as escape. I recently got the new MacBook Pro 16" that has an escape key, but I still use caps lock now.


I mapped caps lock and return on hold to ctrl. This makes the layout symmetric and can type the keys with other hand, similar to shift.


I swap Ctrl and Caps Lock on every computer I use. Even if you’re not using emacs, you end up using ctrl way more often than caps lock.


You can do all kind of weird stuff with xkb on Linux, eg remap Tab to Hyper but keep Alt+Tab/Ctrl+Tab untouched.

Also, fuck RMLVO, let live KcCGST.


If you use KDE there is a nice GUI to setup things like this. I don't use Alt almost ever so I make

Left Alt -> Ctrl

Meta ->Alt

Cpas Lock ->Esc


Same keyboard. I just set caps lock to be Esc on tap and ctrl on hold.


I had ALT mapped to my mouse button in the past.


https://xkcd.com/1172/

CPU-based could be easier.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: