Ubuntu – Trigger Ctrl+key keycode or Hiragana to Control

japanesekeycodes

I have a JIS keyboard with Katana & Hiragana keys I am trying to bind Control keys.

I tried editing the following file JIS Keyboard Layout Keyboard Characters but it fails to change the keyboard keys.

Is there a way to bind keys using keycode for Ctrl+L, etc… I need Hiragana to me mapped to control essentially but it doesn't seem possible.

Best Answer

For CUI:

There are some handy packages to manipulate each key and mouse button.
For the packagesxmodmap xbindkeys xdotool and xte are popular.

sudo apt install x11-xserver-utils
sudo apt install xbindkeys

Use xev and press the Hiragana/Katanaka key and you get the code.

KeyPress event, serial 37, synthetic NO, window 0x3e00001,
    root 0xe5, subw 0x0, time 3469373, (-29,-117), root:(36,405),
    state 0x0, keycode 101 (keysym 0xff27, Hiragana_Katakana), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0x3e00001,
    root 0xe5, subw 0x0, time 3469469, (-29,-117), root:(36,405),
    state 0x0, keycode 101 (keysym 0xff27, Hiragana_Katakana), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Alternatively, you can use xbindkeys -mk to get the keycode and numbers.

$ xbindkeys -mk
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.

--- Press "q" to stop. ---
"(Scheme function)"
    m:0x0 + c:101
    Hiragana_Katakana

I do know know the codes are the same as your IBM keyboard layout. You should check on your own keyboard. The numbers may be different.

Now then, edit ~/.xbindkeysrc add lines below. (if there's no such file xbindkeys --defaults > $HOME/.xbindkeysrc to create one.

"xdotool key ctrl+l"
 m:0x0 + c:101 + release

Save this file and
pkill -f xbindkeys && xbindkeys
execute this command to apply changes.


For GUI

Open System Settings > Keyboard > Shortcuts

Shortcuts Window Control+L

This one takes only a minute.

Related Question