Score:3

Keyboard remap [Alt_L] + {ijkl} as arrow {Up, Left, Down, Right}

vn flag

I want to use 'ijkl' together with alt to act like arrow keys. i.e. Alt+i = Up , Alt+K = Down etc.

I have tried xmodmap following this answer. The answer says that Alt modified key is the third column in xmodmap. Yet, xmodmap -e "keycode 31 = i I Up" does not assign up to Alt+i.

I have also tried xbindkeys following another answer. But this does not work as well.

"xvkbd -xsendevent -text '\[Left]'"
m:0x18 + c:44
alt + j

"xvkbd -xsendevent -text '\[Down]'"
m:0x18 + c:45
alt + k

"xvkbd -xsendevent -text '\[Right]'"
m:0x18 + c:46
alt + l

"xvkbd -xsendevent -text '\[Up]'"
m:0x18 + c:31
alt + i

I would much appreciate a solution, preferably that does not break other alt combinations that I have like ctrl+alt+t to open terminal etc.

edit: (if it helps for the answer) after I do xmodmap re-assignment when I run xev and press Alt+i it returns the following.

KeyPress event, serial 37, synthetic NO, window 0x2e00001,
    root 0x66b, subw 0x0, time 35626163, (161,-15), root:(261,144),
    state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 37, synthetic NO, window 0x2e00001,
    mode NotifyGrab, detail NotifyAncestor

KeyPress event, serial 37, synthetic YES, window 0x2e00001,
    root 0x66b, subw 0x0, time 0, (1,1), root:(1,1),
    state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic YES, window 0x2e00001,
    root 0x66b, subw 0x0, time 0, (1,1), root:(1,1),
    state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic YES, window 0x2e00001,
    root 0x66b, subw 0x0, time 0, (1,1), root:(1,1),
    state 0x0, keycode 111 (keysym 0xff52, Up), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic YES, window 0x2e00001,
    root 0x66b, subw 0x0, time 0, (1,1), root:(1,1),
    state 0x0, keycode 111 (keysym 0xff52, Up), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusIn event, serial 37, synthetic NO, window 0x2e00001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 37, synthetic NO, window 0x0,
    keys:  4294967216 0   0   0   0   0   0   0   1   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

KeyRelease event, serial 37, synthetic NO, window 0x2e00001,
    root 0x66b, subw 0x0, time 35628444, (161,-15), root:(261,144),
    state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

First, I do not know why Shift_L shows up. Second, it shows that Up keypress even is registered somehow, yet it does not have any effect, for example it does not move the cursor up.

(I use Ubuntu 20.04)

Sadaharu Wakisaka avatar
pl flag
Welcome to AskUbuntu, does [this](https://askubuntu.com/questions/490052/trying-to-map-ctrlhjkl-to-left-down-up-right-globally-vim-like-arrow-key?rq=1) help?
adal avatar
vn flag
First, thank you. Second, the answer there refers to [here](https://superuser.com/questions/96299/mapping-superhjkl-to-arrow-keys-under-x) which is what already what I did with *xmodmap* and it does not work. (I even tried to assign alt_l to Iso_level3_shift [which already broke all other alt+ shortcuts] yet it does not move the cursor as arrow keys supposed to do)
Andra avatar
tr flag
you say that `xmodmap -e "keycode 31 = i I Up"` doesn't work, but did you also `xmodmap -e "keycode 64 = Mode_switch"`?
adal avatar
vn flag
yes I did. But when I do that all other 'Alt' related shortcuts break. For example Ctrl+Alt+t is the binding that opens the terminal in Ubuntu, but when you remap Alt to Mode switch it no longer works.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.