25

I have installed mozc (a Japanese input method editor (IME)) on Ubuntu 14.10. It is working fine. I am able to write in Japanese by going to the icon in the upper-right-hand corner of my screen (what do you call this?) and selecting Hiragana or Katakana from the "Input mode" menu, as in the picture below:

mozc Input Mode menu

However, this is a very slow process. I imagine there has to be a faster way to switch input modes - a keyboard shortcut or something (like on Windows with Google Japanese Input [to which mozc is related], Alt+` switches between Hiragana and Direct Input). What shortcuts are there for switching input modes, and can they be configured?

2
  • 1
    Related: By default, to switch between ibus languages, the keyboard shortcut is Super+Space. For me, this is LeftWin+Space.
    – kevinarpe
    Apr 18, 2022 at 13:53
  • If anyone is looking for a solution to this in 2024, and you can't be bothered to read paulolimac's essay, a quick solution is here: askubuntu.com/questions/561486/… Mar 11 at 0:01

4 Answers 4

19

TLDR

Abstract

Steps to create the Japanese Mozc key bindings, to switch the input modes:

  1. Open a text editor (e.g. Gedit).
  2. Click on Gnome Status menu (Gnome's top-left bar) > IBus menu (i.e. keyboard/input language selector) > Select Japanese Mozc input method.
  3. Again, click on Gnome Status Menu > IBuz > tools > Properties > Mozc Settings window.
  4. From Keymap style section > click on customize button (first one).
  5. Create new entries with your personal shortcuts to duplicate the japanese keys binding: hankaku/zenhankaku, muhenkan, eisu.
  6. Run ibus-daemon -drx to reload and take configurations into effect if necessary.
  7. If messed things up, click on reset to defaults button from Mozc Settings window.

That's all!

Graphical abstract

Steps to create the key bindings to toggle Japanese syllabaries input mode.

Graphical Abstract to set up MOZC keys

Introduction:

The problem: how to type Japanese using a non-Japanese keyboard?

In Japanese (日本語, nihongo), you need to write using a lot of different symbols-sets. A informal categorization of these sets can be like:

  • all alphabets syllabaries (ひらがな hiragana, かたかな katakana, 漢字 kanji, ローマ字 romaji),
  • (han)dakuten, contractions, combinations and variants (e.g. ゜maru, ゛tenten, uppercase, lowercase, full-width, half-width etc),
  • symbols in Japanese style (e.g. Japanese period。, 「Japanese quote」, Japaneseーhiphen etc).

So, dedicated keys exists on Japanese keyboards to toggle between them. An analogy with occidental keyboard are the Capslock key to upper/lower-case or, Shift key to insert symbols. But the occidental keyboard hasn't these Japanese keys. So how to type in Japanese using a non-Japanese keyboard?

Solutions

Basically, two solutions can be listed:

  1. install a Japanese keyboard or,
  2. binding Japanese keys, by software level, in your non-Japanese keyboard.

Solution 1: Install a Japanese keyboard

Easiest solution so far. Acquire one Japanese keyboard, install and configure on your Operation System. But you need access to one, maybe buying one (with international credit card, taxes, waiting for shipping and so on).

Solution 2: Binding Japanese keys in your non-Japanese keyboard.

It is a cheap solution and you can use it in any keyboard you have. But you need to install software, configure, and memorize MANY key combinations. It is basically "a sea of shortcuts" to emulate the Japanese keyboard. Linux have some software to simulate a Japanese keyboard for using a non-Japanese keyboard.

Let's implement the solution 2.

Theoretical background

Linux input software layers

Our computer can receive inputs from many talked/typed languages and hardware (i.e. different keyboards and layouts). So it needs to organize the configurations and permit to the user choice between different languages. For example, a user can type one document in Italian AND English languages, at alternating times. So the software needs to show the user a way to change the language to be inputted.

The Linux user have 2 layers of software to configure the input method by keyboard:

  • Input Method Framework (IMF): a class of software that organize the inputs (from keyboard, mouse etc), send to the correct destination (software, systems etc), and configure them.
  • Input Method Editor/Engine (IME): a class of software that receives the inputted characters (from a keyboard), translate them to the desired input (i.e. idiom, language) and, send them to the Input Method Framework (IMF) to handle them. Basically, we have: from keyboard > (typed/inputted keys) > IME (receives and translate them) > (translated inputted keys) > IMF (handle translated inputted keys to destinations).

For the Linux user, an example o IMF is IBus; an a example of IME is MOZC. The first one will switch between all installed IMEs and switch between all idioms/languages installed too. The second one, if selected, will send to the IMF only Japanese keys, even if you typed in a non-Japanese keyboard. About Japanese IMEs, you can read more about here, and visualize the states/events in these diagrams:

Diagram 1: IME states 1

Diagram 2: IME States 2

Japanese keyboard

Layout

The Japanese keyboard layout (キーボード) is established by Japanese International Standard (JIS). First of all, let's contemplate the Japanese keyboard! Watch an open box video. You can see the vector draw bellow, showing clearly the Japanese keys:

Japanese keyboard layout

Finally, some real pictures bellow:

Japanese keyboard layout 1 Japanese keyboard layout 2

Try to identify each key, slowly.

We have:

  • Roman letter (QWERTY).
  • Hiragana symbols.
  • Small hiragana symbols.
  • Han-dakuten symbols (maru, tenten).
  • Arithmetic symbols.
  • Capslock, shift, super, alt, tab, Ctrl, Enter, Backspace.
  • Punctuation with Japanese style (period, quotes etc).
  • and some special keys with Japanese words:
    • muhenkan 無変換: don't convert kana to kanji.
    • henkan 変換: convert kana to kanji.
    • hiragana/Katakana/romaji カタカナ / ひらがな / ローマ字:
    • hankaku/zenkaku 半角 / 全角: switch between half-width or full-width
    • kanji 半角 / 全角 / 漢字: switch between kanji or English characters.
    • eisū 英数: switch to alphanumeric characters.

You can have more description of these specific keys here. And read about the text frequency of hiragana, katakana e kanji and here.

Typing

How a Japanese user type on this keyboard?

  • Answer 1: type phonetically, using romaji mode. Yes, they use romaji!
  • Answer 2: it can type in kana mode, too, using hiragana keys.

For example, lets type "kakikukeko" in romaji mode:

  1. First, select romaji mode.
  2. Typing, in a QWERTY keyboard:
    1. type k, outputs: .
    2. type a, outputs: (ka).
    3. type k, outputs: かk.
    4. type i, outputs: かき (kaki).
    5. type k, outputs: かきk.
    6. type u, outputs: かきく (kakiku).
    7. type k, outputs: かきくk.
    8. type e, outputs: かきくけ (kakikuke).
    9. type k, outputs: かきくけk.
    10. type o, outputs: かきくけこ (kakikukeko).
    11. type ENTER, outputs: かきくけこ (kakikukeko ).

Another example, type "kakikukeko" in hiragana mode.

  1. First, select kana mode.
  2. Typing, in a QWERTY keyboard:
    1. type t, outputs: (ka).
    2. type g, outputs: かき (kaki).
    3. type k, outputs: かきく (kakiku).
    4. type :, outputs: かきくけ (kakikuke).
    5. type b, outputs: かきくけこ (kakikukeko).
    6. type ENTER, outputs: かきくけこ (kakikukeko ).

And to convert to katakana or kanji is the same thing. You can toggle to katakana mode or kanji mode and type on romaji or hiragana. And the computer will pop up an autocomplete window to you select your desired word.

Method

Now, we will use software to type Japanese in a non-Japanese keyboard. My system when I create this text was:

  • My OS: Ubuntu 18.04.4 LTS
  • My Japanese IME: Mozc 2.20.2673.102
  • My IMF: Ibus 1.5.17
  • My keyboard: Latin keyboard (with ç, ~, ^ and so on).

Install

Ubuntu came with the IMF IBus (like a built in). But if you need to install IBus:

sudo apt install ibus

Next, let's install our Japanese IME MOZC:

sudo apt install ibus-mozc

Observation: look at the name of the package ibus-mozc. Its our IMF + IME names. So, in future we can search on APT repositories for IMF and Japanese IME alternatives, like ibus-*, or *-mozc.

Installations completed!

Configurations

A Japanese keyboard has many different keys, to switch:

It is necessary to edit and memorize the Japanese input software's (binding) shortcut keys. Hiragana, katakana, kanji, romaji, upper/lower-case, full/half-width, Japanese symbols (period, quote, maru, tenten etc). So, you need to memorize/edit the keys to (des)activate the switches.

See the screenshots from before to get a hint of where the MOZC keymap is. To edit/read these keys on your Mozc:

  1. Open a text editor (e.g. Gedit) and stay with it in foreground.
  2. Select Mozc input mode: Hold Super and press Space as many times as to select Mozc option. Or click on: IBus (at GNOME Status Menu) > Japanese (Mozc).
  3. To read/edit these Japanese key bindings, click on: IBus (at GNOME Status Menu) > Tools > Properties.
  4. After Mozc Setting window popped up, click on: General tab > Keymap section (at bottom) > Keymap Style customize button (first one).
  5. After Mozc keymap editor window popped up, click on: Scroll up and down to memorize and edit the Japanese keymap (bindings).
  6. Probably, you may will toggle between all Mozc's input modes (hiragana, katakana, romaji etc) if you duplicate and edit these binding keys for your chosen shortcuts. Basically, to switch between syllabaries using MOZC, you need to memorize/edit/press:
  • hankaku/zenhankaku key: to turn IME on/off.
  • muhenkan key: to toggle kana syllabaries.
  • eisu key (or shift+muhenkan keys) to toggle latin input (i.e. romaji).

From MOZC's source-code, see the table with all matches to the Japanese JIS special keys, as bellow:

...
Composition Eisu    ToggleAlphanumericMode
Conversion  Eisu    ToggleAlphanumericMode
DirectInput Eisu    IMEOn
Precomposition  Eisu    ToggleAlphanumericMode
...
Composition Hankaku/Zenkaku IMEOff
Conversion  Hankaku/Zenkaku IMEOff
DirectInput Hankaku/Zenkaku IMEOn
Precomposition  Hankaku/Zenkaku IMEOff
...
Composition Muhenkan    SwitchKanaType
Conversion  Muhenkan    SwitchKanaType
Precomposition  Muhenkan    InputModeSwitchKanaType
...

You can consider to study/test other MOZC keys too, like:

...
DirectInput F13 IMEOn
...
Composition Ctrl i  ConvertToFullKatakana
Conversion  Ctrl i  ConvertToFullKatakana
...
Composition Ctrl o  ConvertToHalfWidth
Conversion  Ctrl o  ConvertToHalfWidth
Composition Ctrl p  ConvertToFullAlphanumeric
Conversion  Ctrl p  ConvertToFullAlphanumeric
...
Composition Ctrl t  ConvertToHalfAlphanumeric
Conversion  Ctrl t  ConvertToHalfAlphanumeric
Composition Ctrl u  ConvertToHiragana
Conversion  Ctrl u  ConvertToHiragana
...
Composition F10 ConvertToHalfAlphanumeric
Conversion  F10 ConvertToHalfAlphanumeric
DirectInput F13 IMEOn
Composition F2  ConvertWithoutHistory
Composition F6  ConvertToHiragana
Conversion  F6  ConvertToHiragana
Composition F7  ConvertToFullKatakana
Conversion  F7  ConvertToFullKatakana
Composition F8  ConvertToHalfWidth
Conversion  F8  ConvertToHalfWidth
Composition F9  ConvertToFullAlphanumeric
Conversion  F9  ConvertToFullAlphanumeric
...
Composition Henkan  Convert
Conversion  Henkan  ConvertNext
DirectInput Henkan  Reconvert
Precomposition  Henkan  Reconvert
...
Composition Hiragana    InputModeHiragana
Conversion  Hiragana    InputModeHiragana
DirectInput Hiragana    IMEOn
Precomposition  Hiragana    InputModeHiragana
...
Composition Katakana    InputModeFullKatakana
Conversion  Katakana    InputModeFullKatakana
DirectInput Katakana    IMEOn
Precomposition  Katakana    InputModeFullKatakana
...
Composition Shift Muhenkan  ConvertToFullAlphanumeric
Conversion  Shift Muhenkan  ConvertToFullAlphanumeric
Precomposition  Shift Muhenkan  ToggleAlphanumericMode
...
Composition Kanji   IMEOff
Composition OFF IMEOff
Composition ON  IMEOn
Conversion  Kanji   IMEOff
Conversion  OFF IMEOff
Conversion  ON  IMEOn
DirectInput Kanji   IMEOn
DirectInput ON  IMEOn
Precomposition  ASCII   InsertCharacter
Precomposition  Kanji   IMEOff
Precomposition  OFF IMEOff
Precomposition  ON  IMEOn
...

So, we need to create new shortcuts similar with these, like bellow (these are my shortcut sugestions):

...
Composition Ctrl j  IMEOff
Conversion  Ctrl j  IMEOff
DirectInput Ctrl j  IMEOn
Precomposition  Ctrl j  IMEOff
Composition Ctrl b  SwitchKanaType
Conversion  Ctrl b  SwitchKanaType
Composition Ctrl y  ToggleAlphanumericMode
Conversion  Ctrl y  ToggleAlphanumericMode
DirectInput Ctrl y  IMEOn
Precomposition  Ctrl y  ToggleAlphanumericMode
...

If you are interested, you can read MOZC's romaji-hiragana conversion table.

  1. If you mess the things, click on reset to defauts button at Mozc setting window (opened in Step 3).

If you edit these shortcuts, please consider conflicts with your existing shortcuts from:

  • Operating system shortcuts (Ubuntu).
  • Graphical shell shortcuts (Gnome, KDE).
  • App shortcuts (firefox, gedit, libreoffice, gimp).
  • Personalized shortcuts (your personal shortcuts).

With these key bindings you can type very well in a non-japanese keyboard. We didn't binding the others japanese keys to let you study the subject.

Alternative solutions

Similar softwares

Im using IBus to be my input method editor (IME). But you can switch to other IMF/IME if you desire. Others IMEs are:

  • Anthy: sudo apt install ibus-anthy.
  • KKC: sudo apt install ibus-kkc.
  • SKK: sudo apt install ibus-skk.

The same as to input method framework (IMF), like:

  • Fcitx: sudo apt install fcitx.
    • and you need to change the IME when installing like:
      • sudo apt install fcitx-mozc.
      • sudo apt install fictx-kkc.
      • sudo apt install fictx-skk.

A list of IMF can be found List of input methods for Unix platforms and Linux input method framework brief summary.

Edit keymap file by a text editor

You can manage the keymap saving, editing, import/export and so on. To do that, read the file at source-code. If you wanna, you can download this file and edit it to be imported into your MOZC software.

So, to import/export the keymap file:

  1. At GNOME Status Menu, select MOZC input method.
  2. Again at GNOME Status Menu, select Tools > Properties.
  3. After Mozc Setting window popped up, click on: General tab > Keymap section (at bottom) > Keymap Style customize button (first one).
  4. And after Mozc keymap editor window popped up, click on: Edit button menu (at bottom) > click import from file... or export from file.... With that you can save (export) your keymap editions. And you can to insert a new keymap edited by importing it.

That's all!

References

You may be interested in read this MOZC issue about how to switch between MOZC j-sylabaries. A good answer about MOZC inputs can be found here. A brief about MOZC input at askubuntu. A lot of questions commented about MOZC and input method. Answers to start MOZC in Hiragana mode.

2
  • Following the procedure in the abstract, I eventually settled upon replacing two entries: 1) Ctrl Space : Set input mode to Hiragana (gets me into kana space) 2) Ctrl Shift Space : Set input mode to next kana (lets me switch between ひらがな and カタカナ). Note: If I have to switch to english, I just hit Super Space to let me switch language back to my own language.
    – baltakatei
    Jul 6, 2020 at 15:35
  • i dont see "Gnome Status" anywhere (as per step 2 in the abstract) Mar 15, 2023 at 2:29
4

It seems that on Windows with Google Japanese Input, the Hankaku/Zenkaku key gets automatically remapped to Alt+`. Either this doesn't happen on Ubuntu with mozc, or the Alt+` sequence is being intercepted somewhere (maybe by Unity for the switch-group command?).

In any case, all I needed to do was to go to System Settings > Text Entry > Japanese (mozc) > Settings > General > Keymap style → Customize... and rebind all instances of the Hankaku/Zenkaku key to some other key combination. I was working off of the MS-IME keymap as a base, so I only needed to change the "Activate IME" and "Deactivate IME" commands to something else.

It would have been nice if I could have used Alt+`, but that doesn't seem to be possible. Oh well.

7
  • 1
    I know this is post is pretty old, but it might be worth pointing out that for me, using Fcitx+Mozc you can just press ` to toggle between modes, but pressing Alt+` doesn't work (both of which may be the same with IBus+Mozc). Aug 16, 2015 at 15:40
  • Pressing "Alt + ~" does nothing on two of my Linux installations: Mint, Kubuntu (removed the default Alt + ~ combination from settings). So, does anyone know which key is assigned to the "change mode" in Linux? Nov 12, 2016 at 16:44
  • This solution doesn't work on 18.04 LTS Apr 28, 2019 at 5:27
  • can confirm does not work on 18.04 LTS
    – Fuseteam
    Mar 21, 2020 at 2:13
  • @DavidBailey I also fought with this for over an hour. I found the source code for mozc that does not allow Alt modifier on non-Apple platform: github.com/google/mozc/blob/master/src/gui/config_dialog/… As a workaround, switch to ibus-anthy, then edit key binding for on_off (switch between hiragana and romaji input). I use Shift+Meta_L which is better known as Shift+LeftAlt.
    – kevinarpe
    Apr 18, 2022 at 13:51
2

I wasn't able to get it to work on ibus, but if you switch from ibus-mozc to fcitx-mozc input, you can use the ` key as the zenkaku (全角) toggle key to switch between romaji and hiragana input without going to the drop-down menu.

To switch to fcitx from ibus:

  1. Open Language Support
  2. Under Keyboard Input Method System, select fcitx
  3. Log out and back in
  4. Open Text Entry
  5. Click the + button
  6. Select Mozc (Fcitx)
  7. Click Add
-4

I'm using Ubuntu 16.04. If you click on the orange あ in the top corner you can go down to 'text entry' settings. Here it tells you how to switch between them by just using the keyboard. On my version it says Command + Space allows you to switch between English and Japanese without having to point and click. It works like a charm on mine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .