3

I ran a search for this, but the answers I saw were referring to something altogether different than what I'm asking for. So let me clarify: I'm not asking how to change key-combo shortcuts. I'm asking--how do you actually change what your computer thinks you did when you press a given key?

An example of what I mean (and the reason I'm asking). I'm a Chrome user, and I use Windows alongside Ubuntu. I own a Lenovo Thinkpad T61p--it came with my scholarship package, and I would have shopped for a nice computer if I could have. The T61p has two buttons above the left and right arrow keys that relate to browser commands to go back and forth one page. This is extremely frustrating for me, as I use the arrow keys, and a single accidental keystroke will catch me going back a page, losing temporary data, and yelling at my stupid keyboard. At the same time, I'm the type of person who keeps way too many tabs open. Chrome doesn't let me refigure keyboard shortcuts, and the only way it allows you to switch between tabs are ctrl+tab and ctrl+shift+tab, and ctrl+page up/down.

I was using Notepad++, and they had finally found the solution to both problems! The page back and forth keys functioned as tab back and forth keys. I went through quite some effort to learn how to change the keybindings in Windows. The page back and page forward keys are now the page up and page down keys, respectively, and if I hit control, they let me switch tabs easily, and rather pleasantly. And if I hit the keys by accident, no harm, no foul.

Alas, I'm in Ubuntu now, and I need to go through the process again. And while I couldn't just find the answer online, like I did for Windows, I know Ubuntu has nice, supportive communities like this one, where, hopefully, somebody can tell me how to do either what I did in Windows, or directly make it so that my computer changes tabs when I hit those buttons (removing the ctrl button from the tab-changing command).

1 Answer 1

6

You should be able to do this using xmodmap- see here for documentation and here for more information. The command will be something like xmodmap -e "keycode <key code>=<key sym>".

You can determine key code and key sym names for the keys in question by opening Terminal and running xev. Once this is running press the key in question and something similar to this will show:

KeyPress event, serial 33, synthetic NO, window 0x5800001,
root 0x15a, subw 0x0, time 117923881, (73,50), root:(736,103),
state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (61) "a"
XmbLookupString gives 1 bytes: (61) "a"
XFilterEvent returns: False

The third line gives both the key code (here, 38) and the key sym (0x61).

To make this new mapping permanent, you'll need to have these commands run at startup by adding them to System > Preferences > Startup Applications.

2
  • Not the most... intuitive solution, but I managed to do it without electrocuting myself or turning my computer into a brick, so thanks.
    – Daniel
    Jan 2, 2011 at 21:18
  • @Daniel - I agree, not very intuitive, but that's all I could dig up. Glad it worked!
    – goric
    Jan 3, 2011 at 1:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .