Ubuntu – How to remap a key combination to a single key

keyboardkeyboard-layout

I'm using Ubuntu on a Samsung Chromebook. As some of you may know, the keyboard used in ChromeOS based netbooks is a bit awkward: amongst other things, it doesn't have a Del key*. If I were going to use this netbook to its original purpose, browsing, I guess it wouldn't be a problem, but I need to program with it, and I miss a lot of keys, specially the Delete one, but also Page Up, Page Down, home and End.

So I've been looking for a way to remap Alt+Backspace to Page Up, Alt+left arrow to Home, Alt+down to Page Down, and so on…

I have found a lot of explanations on how to remap one key, but I don't know how I can remap a key combination to a single key. Has anyone tried to do something like this?

Thanks a lot.

*I mean, the key that deletes a character to the right. We call it "Supr" in Spain, I am not sure how it's in english-speaking countries.

Best Answer

You can use xbindkeys to grab the keys and xvkbd to send keys.

Create a file .xbindkeysrc in your home directory and paste this text:

"xvkbd -xsendevent -text '\[Delete]'"
  Alt + BackSpace

"xvkbd -xsendevent -text '\[Home]'"
  Alt + Left

"xvkbd -xsendevent -text '\[Page_Down]'"
  Alt + Down

Then start xbindkeys and it should work. Probably you want to map more keys, then after you edited the .xbindkeysrc you can run pkill -HUP xbindkeys to send a HUP signal to xbindkeys (or kill xbindkeys and start it again).

To see the key names that xbindkeys sees, you can run xbindkeys -mk (man xbindkeys has more info).

To see the key names that xvkbd knows, have a look in /usr/include/X11/keysymdef.h (maybe someone else knows a better method?).

xbindkeys only runs until your X session ends, so you probably want to put it in your startup (auto-start) programs.

Related Question