Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Compose Key on macOS (github.com/granitosaurus)
42 points by wraptile on Sept 22, 2020 | hide | past | favorite | 43 comments



In case you never tried this: pressing [control] + [command] + [space] will open an emoji picker in most (all?) places in macOS.


In keyboard settings (at least in Big Sur) this can also be rebound to tapping fn, which is quite useful for typing math.


For Windows users, 'WIN + .' does this also - however I've found some differences from the emoji graphic shown in the popup, to the graphic actually pasted in the application.


Some web-based applications (most notably Facebook and Twitter) will replace emoji characters with their own custom graphics to guarantee that what the poster sees is what the reader will see since emoji appearances can differ slightly between fonts and thus operating systems.


Congratulations. I have a US keyboard and often find myself having to type accents when writing in non-English languages. I've found that the easiest way to do this is to use the Compose key feature built into KDE, and to use Wincompose on Windows.

macOS however already has built in Option + key chords for most accented characters, so I rarely need to use a Compose key there.

That said, I imagine having a Compose key on macOS would be useful for typing custom characters, emojis and Unicode.

Compose Key

https://en.wikipedia.org/wiki/Compose_key


For your future reference, I'm Brazilian and have always used US keyboards.

Every OS and DE I've used has the option to configure a US keymap with "dead keys", which works similarly to a typewriter - you type, for instance the acute accent (') and the cursor doesn't move until you type the next key, so if you do 'a it gives you á, 'c gives you ç, ~o gives you õ etc.

On macOS, I personally use the Brazilian - Pro mapping but there might be others. There's nothing particularly "Brazilian" about that mapping either so it might just work for you regardless.

I recall using one called "US International" or something similar on Windows and Linux.


Ah yes, I looked into US International. However the fact that the accent deadkeys (', `, ~, ^, ") are common punctuation kinda messes up my coding productivity, so I had to find another way.

macOS's Option + key chords are highly productive but aren't supported on all platforms, so I settled on the Compose key as a compromise. (my Compose key is mapped to the Menu key on Windows keyboards which almost nobody ever uses -- in contrast the Windows key is used a lot)

Compose keystrokes are slower because they are sequences and not chords, but they're intuitive enough and work well for me.


On the Mac I have 2 input sources configured (one with, one without dead keys) and a shortcut to switch between them.


US International is indeed the keyboard layout most would recommend for people who need compose keys. Except it's absolutely utterly pants for developers, who need the single-quote key more often than they'll ever need a compose. At least that's my experience.

Many (most?) Windows layouts that are not US, like English-UK, will likely have combos with AltGr that are more useful than US International.

I use Colemak, which has a compose triggered with AltGr+` and a bunch of others. I couple that with AutoHotkey to trigger it via CapsLock, as documented here: http://blog.pythonaro.com/2020/06/better-access-to-special-c...

MacOS is a different beast, I currently do stuff with a programmable keyboard but Alt+` is a pretty good compose combo.


Doesn't it annoy you when you want to type 'a quoted sentence beginning with one of them'?


I would think you would just strike ' then <space>. I would think it would be less annoying over all if you use accents a lot.


That, and the fact that I have a keyboard shortcut to switch quickly when I need.


?

On MacOS to get accents you just "hold <vowel>, and press <number in pop up for the accent you want>".

For ü, "hold u, press 2".

You don't need to use "Option" for anything.


Holding the letter is the new way. Back in the day we had to use Option.


What do you precisely mean by "back in the day" ?

I've been "holding the letter" for 5 years at least.


I started using Mac OS X in 2003 and my habits are from that time. The Option + key was the only game in town then.

I’ve also used System 6, 7 and Mac OS 9 so I have habits from that time too.


I prefer using ⌥ to be honest, because I like my key repeat.


When on Linux or Windows, one of the most annoying things for me is that they use a Compose key, that requires me to 'AltGr+"' to write ü.

On MacOSX, I just hold u, and a menu appears, that allows me to select ü by just pressing 2. So I end up just doing u+2. With the huge advantage that I don't have to remember the combinations.

Similar for emojis and pretty much anything else you'd like to type as others have mentioned.

So the only question i have is: why? Really. Why would anyone go through the trouble of porting compose keys to macosx, when macosx native solution is so much better?

Time would be better spent on porting MacosX solution to Linux, Windows, et. al.


> So the only question i have is: why? Really. Why would anyone go through the trouble of porting compose keys to macosx, when macosx native solution is so much better?

The only reason I can think of is that some people like to have the hold key action repeatedly type the specified character and the compose menu gets in the way of that. This is a relatively clever way of keeping both features active without having to repeatedly resort to terminal commands.


What do you mean by "hold u"? Holding u just repeats the key, right?

Why is macosx system is better? Compose keys are mnemonic: e + . = ė ‒ you don't need to remember any abitrary codes and there are no popups or any implicit accidents.

I've tried many different schemes etc and compose key is still my favorite system and having unified system for linux and macos is big bonus for cross platform users. At the end of the day it's just another option! :)


> What do you mean by "hold u"? Holding u just repeats the key, right?

No, it does not. Holding u briefly overlays a keyboard of "compositions" for u, and you can just press whatever key you want afterwards to pick one, see: https://osxdaily.com/2017/03/22/type-accents-mac-easy/

> Why is macosx system is better? Compose keys are mnemonic

Because macosx system is not mnemonic. If I need to type a particular accent, which I do very often, and there are O(50) variations of them, I don't have to remember anything. Instead, the computer shows me all the options as a type, and I just pick the one I want.

---

If I need to type "u" 42 times for whatever reason, holding u and waiting sucks anyways. Every editor I use has a better more precise way of doing this (on my emacs its just meta+42+u), and worst case I can always just do cmd+space and execute "repeat 42 u" or similar.


By default holding down a key does not repeat it. I suspect you’ve probably turned that behavior off.


oh I didn't know that was the default though I can't imagine using a keyboard without key repeat!


I had to disable it so I could use vim properly unfortunately.


I feel like this could be done via the built-in text expansion shortcuts (prefs>keyboard>text). Like *wai expands to 'praying hands emoji'. (I just tested it, this works.)

Also as others have noted, cmd-ctrl-space opens the Character Viewer, which lets you search the entire unicode space, including emoji, for characters. Hit the gear at the upper left and do 'customize list' to pick just which sets you like, I have never actually had a need to type 𓂀 but who knows what the future will bring?


Yeah the keyboard preference map does work in a similar fashion! However I came into few problems with it that are rather minor but bugged me nevertheless:

1. It enters the text and _then_ replaces it which for me is really distracting.

2. It has this little pop up even for a single option which is also very distracting.

Maybe it's my niche use case but I type and read a lot and I prefer the input to stay visually minimalistic to not tire myself out.


This is cool and potentially useful. I can imagine turning caps lock into Compose.

I will note two alternatives, depending on what you're trying to do:

* System Preferences > Keyboard > Text lets you specify replacements. For example, if I type ! ? (without the space) I get ‽, because who doesn't want an interrobang?

* https://matthewpalmer.net/rocket/ Rocket lets you add emoji anywhere using a syntax like Slack's


Congrats on getting a project out the door, but I have to ask how is this better than Text Replacement built into macOS/iOS?


Thanks! I'm kinda repeating myself but major differences:

1. Text Replacement enters the text and _then_ replaces it which for me is really distracting.

2. It has this little pop up even for a single option which is also very distracting.

The benefit of it however is that it's more stable (as mentioned in README so apps ignore user keybinds for some reason)


The other plus of text replacement is synchronization. I have a bunch of LaTeX style symbol names mapped on my Mac but they work just as well on my phone. I’m typing this on a phone and \Omega is automatically replaced with Ω or a favorite of mine \shrug becomes ¯\_(ツ)_/¯.

I also spend time on Windows and nothing seems to come close to this convenient (win-. has a few useful things like the character picker panel in macOS but to get more, tools like autohotkey feel really cumbersome).


I have sshrug for ¯\_(ツ)_/¯, and mdshrug for when I'm sending it somewhere that has markdown ¯\\\_(ツ)_/¯.


I have used atext[1] and textexpander[2] extensively in the past and both work well, but it's always bothered me that the software reading my keystrokes wasn't open source.

This is very good! Congrats!

[1] https://www.trankynam.com/atext/ [2] https://textexpander.com/


>Mac os doesn't come with a compose key feature built-in.

Actually it does. The entire Japanese & Chinese input systems are built exactly on that system.


While this can be achieved using existing tools such as Karabiner-Elements [1], it might be overwhelming for some to configure the said tools. I like how simplistic your tool it :)

[1]https://medium.com/@nikitavoloboev/karabiner-god-mode-7407a5...


Karabiner, in all its various incarnations, never delivered for me.


I‘m German and use English Layout. From time to time I have to write on umlaut. And I always type alt u u for ü. I think alt is the compose key here. Alt u just adds dots and the second u gets combined. This works the same with öä (alt u a, alt u o). It also works with ~ but I never went that far since my problem is solved. I try to configure the same on Linux/windows but couldn‘t get the same keys to work so far. macOS only has one alt key and linux doesn’t allow the left alt as compose key. At least not in arch.


Nice work!

In Linux I've put compose and dead greek (with shift) on the right alt, caps on the right ctrl.

I still wish keyboards were different, some keys to the left of the keyboard would be nice.


It’s unclear, will this work with a real compose key? My primary keyboard is a Sun Type 7 and it’d be pretty neat to put it to more full use.


Out of curiosity, have you tried Karabiner [1] for fully utilizing that keyboard? I'm considering to buy a Type 7 keyboard for nostalgic reasons, and it would be neat to be able to use all the special keys on a Mac.

[1] https://karabiner-elements.pqrs.org/


if it's an unique key signal it should work just fine! You just might need to rebind it to a character signal first (like non-us-backslash §). Actually any mechanism that can deliver key character signal should work.


Compose is USB 07:0065 ‘Keyboard Application’ which is identical to the Menu-icon key on PC keyboards.


Is there a repository of cool karabiner techniques?


I like it!




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: