A picture of dkssud, typed on the English keyboard by mistake, turning into ์•ˆ๋…•

dkssudgktpdy ๐Ÿ‘‹

I forget the ํ•œ/์˜ key a lot, the key that switches between Hangul and English.

I meant to type ์•ˆ๋…• (hi) and the screen shows dkssud. I usually notice around then. I delete it, press ํ•œ/์˜, and type it again. The other way happens too. I go to type transformer and get ใ……ใ„ฑ๋ฌธ๋ž˜๊ทฟใ„ฑ.

I looked for similar apps. There are quite a few. The ones that flip what you just typed when you hit a shortcut still need me to notice I got it wrong first. There was also an app that fixes it on its own when you press space, but it only fixed English typed in Hangul mode, and you had to install its own input method. Russia has an app thatโ€™s like the original of this genre, but on a Mac it only does English and Russian.

I couldnโ€™t find an app that spots Hangul typed in English mode, fixes it, and switches the input method too.

So I made one.

meant lives in the menu bar. Iโ€™m writing, I press space, and if the word I just typed looks like the wrong keyboard, a small window pops up next to the cursor. dkssud โ†’ ์•ˆ๋…•. Press Enter and it changes, and the input method switches to Hangul. I just keep typing from there. I almost never have to press ํ•œ/์˜.

meant demo. In the Notes app, type dkssud and press space, a window asks whether to change it to ์•ˆ๋…•, and pressing Enter changes it and switches the input method to Hangul.


Flipping is easy

๋‘๋ฒŒ์‹, the standard Korean two-set keyboard, and the US English keyboard are paired one key to one key. d is ใ…‡, k is ใ…. So dkssudgktpdy is ์•ˆ๋…•ํ•˜์„ธ์š” (hello) with no dictionary. All you need are the rules that assemble consonants and vowels, including the final consonant, ๋ฐ›์นจ. Itโ€™s doing what the Hangul input method does.

Capitals are a little different. On ๋‘๋ฒŒ์‹, Shift produces tense consonants, the doubled ones. q is ใ…‚, Q is ใ…ƒ. So hello is ใ…—๋””ใ…ฃใ…, and HELLO is ใ…—๋ ใ…ฃใ…’.

The disappointing part is, this only works one way. Hangul typed in English mode still carries the Shift. ใ„ธ is E, ใ„ท is e. From the capitals alone, you can tell the original letters.

English typed in Hangul mode is not like that. On ๋‘๋ฒŒ์‹, Shift changes the letter on only seven keys, q w e r t o p, and the rest come out the same even if you hold it. H and h are both ใ…—. So if you flip ใ…—๋ ใ…ฃใ…’ back, you get hEllO, not HELLO. A Shift that disappeared canโ€™t be read off the letters alone.

Anyway, the hard part wasnโ€™t the flipping. It was when to touch it.

Flipping every time space is pressed is fine. The calculation is cheap. The problem is putting a window up every time. People hate it when something does work they didnโ€™t ask for. If it shows up too often, they turn the app off.

Luckily, most of what gets typed day to day is typed right. Flip ์•ˆ๋…•ํ•˜์„ธ์š” and you get dkssudgktpdy, which is not an English word. Flip hello and you get ใ…—๋””ใ…ฃใ…, which is not Hangul. Only show the window when one side makes sense.

Sometimes both sides make sense. Type and on ๋‘๋ฒŒ์‹ and you get ๋ญ‰. It might not be in the dictionary, but it isnโ€™t a broken word. and makes sense and ๋ญ‰ makes sense. The app canโ€™t know, so I handed those to a shortcut. Press the shortcut after ๋ญ‰ and it changes to and without asking. Space is a suggestion. The shortcut does it.


์•ˆ๋…•์•ˆ๋…•์•ˆ๋…•

The flipping engine was done fast. The real work started at changing the text in someone elseโ€™s app. macOS has a channel for editing another appโ€™s text field (Accessibility), and every app responded differently. Some only act like they changed it. Some change it and then keep reporting the old text for a while.

At first, nothing happened when I pressed Enter. So I set up three methods, and if one failed it would move on to the next, and dkssud became ์•ˆ๋…•์•ˆ๋…•์•ˆ๋…• (hi, three times). The first one had succeeded. I saw the old text and thought it had failed.

Next, the cursor went to the very front. Blank lines disappeared too. I was writing the whole text back in just to change one word. I made it change only the word and move the cursor by counting, and this time the cursor stood in the middle of the word. Some text fields count Hangul as characters, some count it as jamo, the separate consonant and vowel letters, so the count was never going to come out right. For nearly an hour, every time it was wrong in a slightly different way.

So I decided to fix it the way a person would. Select as many characters as Iโ€™m replacing, with Shift+โ†, delete, and put the new word in. Donโ€™t ask the app. Do it from the keyboard. Almost every app takes keystrokes the same way, and the cursor stays at the end of the word you put in, on its own.

Two more places still caught me. If you delete Hangul while youโ€™re still typing it, only the final consonant comes off, the ๋ฐ›์นจ. Delete an underlined ๋ญ‰ and only the ใ…‡ disappears. So I finish the composition first, then replace. Notion ignores Cmd+V sent by the app, so I had to send it as if the keys had been pressed on the keyboard before it would go in.


How do you know itโ€™s wrong?

I was typing HUD๊ฐ€ ๋–ด์„ ๋•Œ (when the HUD showed up). I typed HUD in English, didnโ€™t switch ํ•œ/์˜, and typed ๋–ด์„ right after. The screen showed EjTdmf. I did it on purpose. This is the situation the app is for.

The window didnโ€™t show.

ใ„ธ and ใ…† only come out if you press Shift. Thatโ€™s why E and T are capitals. The app saw mixed-case EjTdmf, took it for code like getValue, and left it alone. A rule I added so I wouldnโ€™t wreck code was blocking the case that mattered most. I changed it so that if the flip comes out as whole Hangul, the window shows even when the case is mixed.

The other direction had something similar. ใ…”ใ…‘ใ…œใ…œใ…‘ใ…œใ…Ž is pinning, and the window didnโ€™t show. pinning wasnโ€™t in the English word list the app has. Adding it to the list would have ended it. But then every missing word means another app update.

I changed the question. Donโ€™t only ask whether the result is a word I know. Also look at whether what I just typed is weird. ใ…”ใ…‘ใ…œใ…œใ…‘ใ…œใ…Ž is weird even if you donโ€™t know pinning. Itโ€™s only jamo in a row. If either one matches, show the window.

Then ใ…‹ใ…‹ใ…‹ (laughter) shows up too. ใ… ใ…  (crying) too. Those were typed right, though. I can cancel then. And so the same text doesnโ€™t get corrected later, pressing Tab while the window is up means donโ€™t ask about that word from then on.

I loosened it, and this time it was too loose. I typed MLOps and it asked if I wanted ใ…ขใ…’ใ…”ใ„ด. MLOps isnโ€™t in the English word list, so it looked weird. But nobody was trying to write ใ…ขใ…’ใ…”ใ„ด. I tightened it again: when changing English into Hangul, only ask if the result is whole Hangul characters.

So, right now, it asks in these cases.

  • Hangul typed in English: four or more letters, not in the English word list, and the flip is two or more Hangul characters whose jamo arenโ€™t loose.
  • English typed in Hangul: the typed text has loose jamo, or the flip is an English word of four or more letters thatโ€™s in the list.
  • Words that mix Hangul and Latin letters are left alone.
  • A word dismissed with Tab is not asked about again.
  • When both sides make sense, like ๋ฌด and an, it doesnโ€™t ask. A shortcut changes them.

Trigger

I thought about two more things with the trigger.

One is that a word also ends on something other than space. A period stuck right on, like dkssud., or closing a quote or a parenthesis. I fixed that. So now the window also shows when a word ends on a period, comma, quote, or parenthesis. The symbol stays, and only the word changes. dkssud. becomes ์•ˆ๋…•.

The other was accepting with space. Press space after a mistyped word and the correction suggestion triggers. To make the change, press Enter. But pressing space and then Enter felt like two actions. It was a hassle. Pressing space twice seemed like it would feel like one action.

But while the window is up, space actually meant โ€œno, leave it.โ€ A suggestion that popped up wrong goes away if you just keep typing. If I turn space into the confirm, someone who was ignoring the suggestion and typing on gets a conversion they didnโ€™t want. I dropped this, over the timing and over not causing that mistake.


I still forget the ํ•œ/์˜ key a lot. Itโ€™s fine now. ๐Ÿ‘

The install file is on GitHub.