Typing Japanese

Type 日本語 on an English keyboard

する programs are written in Japanese, but you don’t need a Japanese keyboard. Every computer already has a Japanese input method (IME): you type the sound in Latin letters, and it turns hyouji into 表示. This page shows how to turn it on and the few keys you need. Then try the typing practice.

01What you need

Japanese uses three scripts: hiragana (あいう), katakana (アイウ) and kanji (表示). An IME lets you type the reading in romaji, shows it as hiragana, and converts it to kanji when you press Space. Nothing has to be downloaded on Windows or macOS; on Ubuntu you install one package.

You will switch between two modes all the time:

Keep your English (US) keyboard layout. The Japanese IME sits on top of it.

02Windows

Set it up

  1. Open Settings → Time & language → Language & region.
  2. Click Add a language, choose 日本語 (Japanese) and install it. You don’t need to make it the display language. This adds Microsoft IME.
  3. Click ⋯ → Language options next to Japanese. Under Keyboard layout, choose English keyboard (101/102 key) and restart. Without this, Windows may assume a Japanese keyboard and your symbol keys type the wrong characters.

Switch modes

03macOS

Set it up

  1. Open System Settings → Keyboard, and next to Input Sources click Edit….
  2. Click +, choose Japanese, then Romaji (not Kana, which needs a Japanese keyboard), and click Add.
  3. Keep ABC or U.S. in the list. In the Japanese source’s options you can turn off Live Conversion if you prefer to convert only when you press Space.

Switch modes

04Ubuntu

Ubuntu’s desktop uses IBus, and the Japanese engine is Mozc (the open-source version of Google’s Japanese input).

Set it up (IBus, the default)

terminal
$ sudo apt install ibus-mozc
  1. Log out and back in.
  2. Open Settings → Keyboard, click + Add Input Source, choose Japanese → Japanese (Mozc). Keep English (US) as well.

Switch modes

Or with fcitx5

If you prefer fcitx5 (common on KDE), install fcitx5-mozc, run im-config -n fcitx5, log out, and add Mozc in the Fcitx configuration. Ctrl + Space then turns Japanese on and off.

terminal
$ sudo apt install fcitx5-mozc
$ im-config -n fcitx5

05Typing in romaji

In Japanese mode, type the reading. It appears underlined. Then:

Most readings are typed as they sound. These are the ones that trip people up:

To getTypeWhy
をwoThe particle is pronounced “o”, but o gives お.
はhaThe particle とは is pronounced “to-wa” but typed toha.
んnnA single n works before a consonant (kansuu → かんすう), but before a vowel, y or at the end, type nn: konnnichiha → こんにちは.
っtt, kk…Double the next consonant: kitte → きって.
きゃkyaSmall ゃゅょ follow a consonant + y. A lone small kana is x or l + kana: xtu → っ.
ー-The long-vowel mark in katakana: ke-ki → ケーキ.
ひょうhyouLong “o” is written おう: 表示 is hyouji, 以上 is ijou.

06Brackets and punctuation

In Japanese mode, a few keys type Japanese symbols instead. These are the ones する uses:

To getPressUsed in する for
「 」[ ]strings: 「こんにちは」
『 』[ then Spacenames that contain hiragana: 『おやつの数』
【 】[ then Space, or type kakko and convertderivations and templates: 【JSON】
( )Shift + 9 0grouping; full-width and ASCII parentheses both work
、,a pause in the punctuation style
。.the end of a sentence in the punctuation style
× ÷type kakeru / waru and convertmultiplication and division
Watch out: in Japanese mode, - types the long-vowel mark ー and / types ・. Neither is minus or division in する. For arithmetic, switch to English mode (or use × and ÷). The same goes for Latin names like x: type them in English mode.

07Typing a する program

Words in する are separated by spaces. In Japanese mode, Space converts, so press it once more after confirming to get a space. On Windows that space is the full-width   by default; する accepts it just like an ASCII space, and it accepts full-width digits and +* too. So you can type a whole line without leaving Japanese mode:

zenkaku.suru
値段 とは 1200 です
値段 * 2
「する」 を 表示する
2400
する

If you prefer ASCII spaces, the Microsoft IME setting General → Space can be set to Always half-width, and Shift + Space types the other width on Windows. Here is how some common words are typed:

WordTypeMeaning
表示するhyoujisurudisplay
とはtohais defined as
ですdesuis (ends a definition)
をwoobject particle
加算するkasansuruadd
以下の手順ですikanotejunndesuthe steps below are
以上ですijoudesuthat’s all (closes a block)

If the IME picks the wrong kanji, press Space again and choose from the list. It remembers your choices, so the second time is faster. You can also add your own function names to its user dictionary.

08Let the editor type for you

You only need to type a name once. In VS Code with the する extension:

Comments and the names of your own variables can be in English, so you only switch to Japanese mode for the words of the language. Ready? Check yourself with the typing practice, go on to the tutorial, or try it in the playground.