1

On windows I use Alt + ijkl to simulate the arrow keys. I do this with Autohotkey. I'm using Ubuntu in VirtualBox to learn how to use it, and to see if it is the right OS for me when it comes to programming.

I found a solution to my problem on: Remap arrow keys to win+ijkl on linux But there is a problem with the accepted solution. I can now use the ijkl keys as arrow keys when I hold down the alt key. But it disables all other functionality of the alt key. This means I can't use things like Alt-Tab anymore. Does anyone know how I can solve this?

If there isn't an option I'd like to use Windows-key + ijkl instead. But how can I reset the changes I made to the Alt-key?

(I wanted to ask this question with a comment on that answer, but I'm new here so this website makes it hard for me to do things. Looks like they want to make it as hard for new users as possible..)

2 Answers 2

0

I found how to reset (all) modifications thanks to this: https://askubuntu.com/questions/29603/how-do-i-clear-xmodmap-settings In short: 'setxkbmap -layout us' fixed it.

I found a better solution than xmodmap: xdotool (http://xmodulo.com/simulate-key-press-mouse-movement-linux.html)

To set up the ijkl keys as arrow keys with the alt as modifier you have to go to settings > keyboard > shortcuts > custom shortcuts
Once you're there, click the '+' button.
Give it a name, and enter this command: xdotool keyup Alt && xdotool key Up && xdotool keydown Alt
after this you have to assign the shortcut. To do this, click on 'Disable' on the right side, and push the shortcut buttons.

It runs 3 commands. The first one sets the state of the Alt key to 'up' (not pressed). The second one sens a key press of (in the example) Up key. The third one sets the state of the Alt key back to 'down' (pressed).

If you want to use Ctrl+[arrow key] you need to make another shortcut with Ctrl+Alt+[letter]. The command it executes needs to be the SAME as without the Ctrl key. This is because the shortcut Ctrl-Alt-[letter] is another shortcut than Alt+[letter], but once 'xdotool key [arrow key]' is executed the Ctrl key is already down, so it will see it as if you have pressed Ctrl+[arrow key]

I also makes it easier to navigate when you hold the Ctrl key if you ignore the Ctrl input on the Up and Down keys. To do this, I used the command: xdotool keyup Alt && xdotool keyup Ctrl && xdotool key Up && xdotool keydown Ctrl && xdotool keydown Alt

1
  • This doesn't work unforunately Mar 30, 2021 at 8:17
0

I used

first install: sudo apt-get install xbindkeys

In the file ~/.xbindkeysrc (hidden file) paste the following:

"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

here is my version for someone who is interested

then in your terminal

start the xbindkeys program: xbindkeys -f ~/.xbindkeysrc

to stop the program from running: killall xbindkeys

some explanation:

  • xvkbd .... is the key event that needs to be sent.

  • the second line is what should be pressed to execute the first command

  • third one is just some comments.

  • `# with this you write a comment

m:0x18 = shift

c:number is the key

how to find keycodes

With xev (open terminal write xev press enter)

by pressing a key, you can see which name the key has.

for shift alt etc. look at state in the Keyrelease event

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.