Hacker News new | ask | show | jobs
Use caps lock as a language switch (marinin.xyz)
33 points by marinintim 3566 days ago
21 comments

Some OSes (I know at least Linux does) support what's called "two-shift caps lock": if you hit both shifts, together, you get caps-locks. If you hit only one (on either side), you get a normal shift key.

This frees up the CapsLock-the-key for whatever you want, and you get to keep CapsLock-the-function. (And, you don't have to "move" it, such as in the "Swap CapsLock and Control" schemes: you get to have normal Control, CapsLock key for whatever you want, and the capslock functionality.)

I mapped my CapsLock key to "Level3 shift" at home, and mapped various interesting characters into the homerow, and space. I figured "_" is a word separator, and space bar is for separating words, so Level3+Space = "_". Level3 + the home row is stuff like ()[]{}; things that are normally way out.

Not sure how good the layout is, since I'm still trying to get used to it, and old habits die really hard. I was heavily inspired by the Neo keyboard layout[1].

[1]: http://neo-layout.org/index_en.html

Thanks for your reply. After reading it, I went out searching on how to enable "two-shift caps lock", because I sometimes need the caps lock (in Brazil almost all government related documents demand caps for items such as your name, etc.), but I also need a good compose key. I've been long using the caps lock key as the compose key, but the lack of an alternative caps lock did annoy me at times. Thanks to you, now I have the solution that perfectly fits my personal needs!
Am I the only one who actually uses caps-lock for its intended purpose on a regular basis? I use it pretty much any time I have to type more than two capital letters in a row, which is frequently when I'm programming.
Do you program in SQL? (I've just pressed Shift and released it after I typed SQL, hey)

Using Caps Lock for its intended purpose means that it's another mode that you need mental resources to keep track of.

Historical aside that's not related to your comment: early Soviet computers modeled after IBM PC had Latin key, that basically worked like Shift, but it changed layout from Cyrillic to Latin and vice versa. This idea died after MS Windows, that didn't (and still doesn't? I don't know) have this option, took over the market.

Has anybody seriously been mentally bogged down by confusion from keeping in mind that they have caps lock on? That sounds entirely implausible.
There is an option in pgAdmin to automatically capitalize keywords. Last I checked though it capitalizes them only in pgAdmin - the actual .sql file is lowercase.
People still use all caps for Sql?
I like to write the keywords in upper case to visually separate them from table/field names.
Doesn't syntax highlighting do that?
When I do SQL, it's usually SQL over psql over SSH-to-database-server. And it's uncommon enough to not warrant any time investment into how to get psql syntax-highlighted.
I write quite a lot of SQL and PL/SQL. Yes, I use Caps Lock as intended.
I use caps lock for exactly what its intended purpose is: I use it as a control key, just like it was on the original IBM PC keyboard.

Just remap ctrl to caps lock and you're set.

As for switching languages, Apple puts that in a fine place by default. It's open-apple and spacebar. Just enough effort to remind you what you're doing with no awkward carpal tunnel key combinations.

I mean, if you want to get historical, the position currently occupied by the Caps Lock was Shift Lock on typewriters, which did the same thing as Caps lock currently does except it affected all keys, not just letters.
Yes, the first computer keyboards I used had both shift lock and caps lock.

If I miss anything, I would like it if shift + caps lock, behaved the same as shift lock.

I alleviate the pain on the joints of my little finger by mapping Capslock to Ctrl.
I've run into a few other people who do so, but I find that I type few enough capital letters that attempting to use an alternate, modal means of doing so (that behaves similar to the shift key but without affecting symbols) just slows me down, even when I want to write a CONSTANT_LIKE_THIS. I find it easy to type a long string of text with the shift key held down.

Consider that typing the above constant with caps-lock would still involve pressing and releasing the shift key twice to type the underscores. I'm sure I could teach my fingers to type it that way automatically, but I find it much easier to have a single way of typing a capital letter rather than two.

I use the caps lock key as an easier-to-hit Super key, which makes it easier to use all the window manager shortcuts that use the Super modifier.

I have also mapped the capslock key to super, but FWIW I've had a lot less trouble hitting the actual super key ever since I started using my ring finger for it (I used to use, and see most people using either pinky or palm, both of which require moving the hand quite a bit).
Depends on the placement and size of the standard super key on your keyboard. Some keyboards make it quite small.
Like many others I didn't originally learn typing in a structured manner. It used to be that I only ever used the left shift key. This works adequately, but means that when holding shift the finger positions for the left hand change. In short, it's a bad habit that hampers accuracy and speed, and may increase the risk of RSI.

A couple of years back I made a concerted effort to learn the dvorak layout and have since become a fairly proficient touch-typist. Consequently, when I use a shift key I always use the hand on the opposite side to the one hitting the letter. My coordination is now good enough that I can type a sequence of capitals quickly and accurately using just the shift keys -- alternating to each side as required -- but that would be silly. I don't even think about using Caps Lock, now, it's just part of my muscle memory for when I type a sequence of capitals.

I suspect that most people who don't see the use of Caps Lock always use just one of the shift keys and hold it down when typing a sequence of capitals.

I use it heavily in Asm,C,C++ for #define's, enums, etc where ALLCAPS or ALL_CAPS tends to be its own namespace for certain things.
I know some people who use capslock instead of shift for producing even isolated capital letters, the idea being that hitting two keys in rapid succession, even if it means one more keystroke, could be easier than timing the hold and release of the shift key. The world's fastest typist apparently also uses the same technique:

http://seanwrona.com/typing.php (see "typing tips" section)

I have a (journalist) friend who did this, but only because they didn't properly understand the shift key - she thought it only was used to access the alternate symbols on the number keys.
I've always wanted to remap a keyboard (and do whatever else) so I could hit numbers/symbols in a modal manner with Caps Lock.

I really, really hate chording.

So do I. Good news, Windows has a feature called sticky keys that makes all the modal keys - shift, alt, ctrl - become modal.
Hmm, interesting. I'm running Ubuntu, so I feel that there must be a good way to hack into this myself (but honestly I'm not sure how to get started.)
My wife does this and it drove me insane when I first noticed. I think she avoids typing in front of me now :)

The toggle-vs-coordination of keystrokes actually makes a fair bit of sense though; its not like we type that many capital letters in an average sentence. For a password which might have a handful of caps, though, it slows you down.

NOT TO MENTION ALL THE SHOUTING ONE DOES IN COMMENT SECTIONS
USE A FOOT PEDAL.
Bah. If I want to deliberately look stupid on the Internet there are much, much better ways that don't require a dedicated key.
I use Caps Lock for all capitalization, in place of shift.
I use Ctrl far more and have swapped the two.
On windows, I have capslock mapped thusly:

If pressed and released without another keypress in between, it sends ESC.

If pressed in combination with another key, it's CTRL.

I haven't found a way to do this dual mapping on OSX, so it's just CTRL there. I use AutoHotKey for this on windows.

I don't have my Mac in front of me, but you can do this using Seil[1] and Karabiner[2]. From recollection, you disable caps-link in OS X settings, use Seil to map caps-lock to control, and then use Karabiner to map tapped-ctrl to escape. Sounds a bit hackish, but it works very well.

You can also do the same thing on Linux using xcape[3]

[1]: https://pqrs.org/osx/karabiner/seil.html.en [2]: https://pqrs.org/osx/karabiner/index.html.en [3]: https://github.com/alols/xcape

This is problematic for Emacs users: You can't put Switch Lang there, you need Control there!

However, you could bind this to lcontrol, and get the capslock light to turn on when it goes.

Also, am I the only one who at some point rebound ralt to rshift? I've stopped doing it now. I don't know what I was thinking.

Language switch is problematic for Emacs users in general, 'cause it messes with bindings.

So when I do emacs I use mule, which is mapped by default as C-/. It is not so bad if you remap Caps to Control, but still not one key.

Well, the idea is that you're using emacs for your code, and then you jump over to your mail client (all the emacs mail clients don't really work for me), and hit a key to switch over to russian, or whatever.
I am a Vim user. Mapping Caps Lock to Esc has been pretty valuable and it only took me about a week to get used to the change.
Have you tried the jk chord? for me, it feels faster because the j key is where my right index finger parks.

:inoremap jk <esc> http://learnvimscriptthehardway.stevelosh.com/chapters/10.ht...

I love the jk chord. No more escape reach for me and vi gets even more vi-nature as the fingers stay where they belong.

I even remap ESC to nop so that I won't ever forget.

Oh, you mean hitting j and k in sequence, not an actual chord.

Is there a way to make it trigger when pressing both keys at the same time? I'd rather not have a letter sequence that can kick me out of insert mode, especially when I'm pasting into my terminal.

No; there's absolutely no way for vim (terminal vim at least, but gvim inherits lots of terminal quirks) to see a chord like that.

But, never fear -- if you paste while in paste mode (:h 'paste or :h 'pastetoggle) imaps, iabbrs, etc. do not get activated. If you paste when not in paste mode then things tend to get messed up anyway and those are probably the least of your worries.

Or paste using the clipboard -- "+p in normal mode, or <c-r>+ in insert mode. (The other clipboard is in the asterisk register, but HN keeps eating the character)

I think you can use Ctrl+C or Ctrl+[ instead of Esc?
I mapped caps lock to ctrl on Windows and to command on MacOS. Using the system wide default shortcuts feels much easier this way, because caps lock is on the same middle row where my fingers usually rest.

I got this idea from the custom layout of the HHKB keyboard: https://elitekeyboards.com/proddata/doc/hhkbp2_basic_layout1...

This is a great tip for chromebooks users, as these machine dont have such key!
Speaking of multilinguals - note that Swiss people actually need capslock to type things like 'Ö' because if you press SHIFT + 'ö' then you get 'é' on a Swiss layout (well, I guess you could type '¨' first and then 'O', that also assembles to 'Ö'). Gotta accomodate for both German and French. Just a bit of trivia you might not have known.
Try the US-International Layout on US-QWERTY. It works well with German and French as secondary languages.

https://en.wikipedia.org/wiki/QWERTY#US-International

The Windows version makes more sense to me, but I'm getting used to the Mac one too.

Indeed. On my bog standard US+International layout I can simply do:

AltGr + e = é

AltGr + p = ö

Adding Shift to the mix produces É and Ö, respectively, as one would expect.

I use Caps Lock as an extra general-purpose function key (F20), which I can then bind as I please depending on the application.

Mapping it as an extra modifier seems a tad unergonomic. Ideally, each modifier key should be located on either side of the keyboard, so that you can always engage it with the opposite hand. To that end, I also remap the Menu key on my MS Natural Keyboard[1] to act as a second Super modifier.

Furthermore, since I'm multilingual and need an AltGr modifier on both sides as well, I map the combo Ctrl+Super to act as AltGr. See my US+International XKB keymap[2] should you happen to want a similar setup on Linux.

[1] https://www.microsoft.com/accessories/en-us/products/keyboar...

[2] https://gist.github.com/ucs1/fe673a3606442911dbd7d016a372646...

I love Caps Lock. It's just a free key on the home row to reprogram to whatever you want. I change mine to ESC for easier Vim interaction.
The caps key is clearly destined for the compose key, quite useful if you sometimes need to type different languages. "şçäë"
Caps_Lock should be mapped to Control_L so you can type it in the home row with less stress to the hand/fingers. (no twisting)

Additionally, one of the better changes I made years ago was mapping redundant/useless modifiers to the bucky bits[1] in my ~/.Xmodmap.

    Phys Key | New Modifier Mapping
    -----------------------------------
    CapsLock | Control
    Alt_L    | Meta
    Alt_R    | Alt   (mod4)
    Win_L    | Super (mod3)
    Win_R    | Hyper (mod5)
To my surprise, quite a few programs support the higher modifier bits.

[1] http://www.catb.org/jargon/html/B/bucky-bits.html

Or you could use the edge of your left palm to hit CTRL. This reduces strain and is much faster.

It's the way I could use Emacs to write my thesis and only wonder about those stories of RSI. On Mac and Linux, I have CTRL-Number set to switch workspaces.

Under windows you don't need to use 3d party apps.

Regedit HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\Your_Language_IME

Set the key modifier to 00 and set the virtual key to the key you want caps lock is 04 iirc. https://msdn.microsoft.com/en-us/library/windows/desktop/dd3...

I think there was also a way to hack it through HKEY_CURRENT_USER\Keyboard Layout\Toggle but I'm not sure if it's used anymore.

I actually think you can take it a step further. I have my caps lock mapped to esc on single press and as opt + control when held but I also use something I call sticky keys that allow me to keep my hands on the keyboard and on the home row at all times.

[Here it is and how I use it.](https://github.com/nikitavoloboev/dotfiles/tree/master/karab...)

CAPS_LOCK -> L_CONTROL.

Long-time emacs use has permanently changed my left pinkie.

I used caps lock as backspace for a long time, I quite enjoyed it.
As an "academic" touch typer, I use Caps Lock as intended (for typing more than 2 all-caps letters in a row), however since I need that much less frequently than Ctrl, I swap Ctrl and Caps Lock on every computer that I call home. As far as switching between 3 keyboard layouts (dvp, Armenian, Russian), I map that to Option+Command+Space, but now that I think about it there's probably a better combination to be found.
I mapped caps lock to left click and then used eviacam to control the mouse pointer with my face. No more keyboard<->mouse back and forth. Works great!
Well this is just magic. I had set it up to Ctrl+Space since I speak Spanish, English and learning Japanese. I am not fluent enough in Japanese yet, but it becomes a burden when trying to write a website in Spanish.

You can just do this instead in Ubuntu: Text Entry Settings => click on "Switch to the next source using" => Caps Lock

I've been doing this for a while. I agree it's the most natural map for a multi-lingual ({en-US, zh-CN, ja-JP} here).

AutoHotkey on Windows 10:

    CapsLock::#Space
    +CapsLock::+#Space
I hold caps lock for ctrl, and tap it for escape. Right then left shift is my caps lock, tap shift to unlock.
I don't even have a caps lock key programmed on my ErgoDox keyboard.