DEV Community

vast cow
vast cow

Posted on

How to Temporarily Change the Keyboard Layout

In a Linux desktop environment, you can temporarily change the keyboard layout using the setxkbmap command.

This is useful if you want to use a US keyboard layout or switch back to a Japanese layout.

Changing to the US Layout

To change the keyboard layout to the US layout, run the following command:

setxkbmap us
Enter fullscreen mode Exit fullscreen mode

This will use the US layout in the current login session.

Changing to the Japanese Layout

To change to the Japanese layout, run the following command:

setxkbmap jp
Enter fullscreen mode Exit fullscreen mode

This can also be used to switch back to the Japanese layout after changing to the US layout.

Checking the Current Settings

To check the keyboard layout currently in use, run the following command:

setxkbmap -query
Enter fullscreen mode Exit fullscreen mode

You can check the current layout by looking at the layout item in the displayed output.

For example, it will display us for the US layout or jp for the Japanese layout.

Note that the Change is Temporary

Changes made with setxkbmap are generally temporary.

Logging out or restarting may revert to the original keyboard layout set by the distribution or desktop environment.

If you want to use the same keyboard layout after logging in, you need to configure a permanent setting. The configuration method varies depending on the distribution you are using, such as Ubuntu, Xubuntu, Debian, or Arch Linux.

If you just want to temporarily switch layouts, it is convenient to remember the three commands: setxkbmap us, setxkbmap jp, and setxkbmap -query.

一時的にキーボードレイアウトを変更する方法

Linuxのデスクトップ環境では、setxkbmapコマンドを使うことで、キーボードレイアウトを一時的に変更できます。

US配列のキーボードを使いたい場合や、日本語配列に戻したい場合に便利です。

US配列に変更する

キーボードレイアウトをUS配列に変更するには、次のコマンドを実行します。

setxkbmap us
Enter fullscreen mode Exit fullscreen mode

実行すると、現在のログインセッションでUS配列が使用されます。

日本語配列に変更する

日本語配列に変更する場合は、次のコマンドを実行します。

setxkbmap jp
Enter fullscreen mode Exit fullscreen mode

US配列に変更したあと、日本語配列へ戻したい場合にも使用できます。

現在の設定を確認する

現在使用しているキーボードレイアウトを確認するには、次のコマンドを実行します。

setxkbmap -query
Enter fullscreen mode Exit fullscreen mode

表示された内容のうち、layoutの項目を見ることで、現在のレイアウトを確認できます。

たとえば、US配列の場合はus、日本語配列の場合はjpと表示されます。

一時的な変更であることに注意

setxkbmapによる変更は基本的に一時的なものです。

ログアウトや再起動をすると、ディストリビューションやデスクトップ環境で設定されている元のキーボードレイアウトに戻ることがあります。

ログイン後も同じキーボードレイアウトを使用したい場合は、永続的な設定が必要です。設定方法はUbuntuやXubuntu、Debian、Arch Linuxなど、使用しているディストリビューションによって異なります。

一時的にレイアウトを切り替えたいだけであれば、setxkbmap ussetxkbmap jpsetxkbmap -queryの3つを覚えておくと便利です。

Top comments (0)