You are not logged in.

#1 2010-04-19 12:02:03

drugcpp
Member
From: Israel
Registered: 2010-03-16
Posts: 20

Mapping Ctrl+key1 to Ctrl+key2

I have a Hebrew layout. In this layout "w" key is mapped to "'" (apostrophe). Because of this Ctrl+w doesn't close tabs in Firefox. This bug was described in firefox buglist 2 years ago, so I guess they don't hurry up to fix it. I thought that I can fix it myself. All I need to do is to map Ctrl+apostrophe to be Ctrl+w. I know that this will be globally and not just for firefox, but I don't care. Anyone knows how to do such mappings?

Thanks in advance smile

Last edited by drugcpp (2010-04-19 12:16:31)

Offline

#2 2010-04-19 12:43:58

Tes--
Member
Registered: 2009-11-13
Posts: 42

Re: Mapping Ctrl+key1 to Ctrl+key2

You can do this with xmodmap, although note that ctrl is a special key, which is handled separately. So it will change the apostrophe to a 'w'. If you want to type a apostrophe afterwards, you will need to assign it to a different key.

Check what keycode the key has that you want to change. Launch xev from a terminal and press the key in question. You will get a keycode somewhere in the output. In your case the keycode is 25.

Check what current functions the key has, by executing

xmodmap -pk | awk '$1 == 25'

In my case the output for key 48 (apostrophe) is

   48        0x0027 (apostrophe)    0x0022 (quotedbl)    0x0027 (apostrophe)    0x0022 (quotedbl)    0xfe51 (dead_acute)    0xfe57 (dead_diaeresis)    0xfe50 (dead_grave)    0xfe65 (dead_abovereversedcomma)    0x0027 (apostrophe)    0x0022 (quotedbl)

You can probably ignore everything after the first 2 arguments, but it depends on your keyboard layout.

Create a file name .Xmodmap in your homedirectory, and put in a modified version:

keycode 25 = w quotedbl apostrophe quotedbl dead_acute etc..

As you can see the first argument is for the key, the second one is if you press Shift. The rest is for other modifier keys, such as alt_gr.

Afterwards, restart X and it should work.

Offline

#3 2010-04-20 15:05:12

drugcpp
Member
From: Israel
Registered: 2010-03-16
Posts: 20

Re: Mapping Ctrl+key1 to Ctrl+key2

I don't want to change my apostrophe in hebrew to be something else because I'm using it. I wanted it to change dinamically to 'w' in case I press Ctrl beforehand. Is there some daemon for tasks like that?

I have 3 layouts: English, Russian, Hebrew
From the command

xmodmap -pk | awk '$1 == 25'

output is

25        0x0077 (w)    0x0057 (W)    0x0027 (apostrophe)    0x0057 (W)    0x1000446 (U0446)    0x1000426 (U0426)    0x1000446 (U0446)    0x1000446 (U0446)

Last edited by drugcpp (2010-04-20 15:08:16)

Offline

#4 2010-04-22 09:30:46

Tes--
Member
Registered: 2009-11-13
Posts: 42

Re: Mapping Ctrl+key1 to Ctrl+key2

I don't think something like that exists.

Maybe you could hack something together using xbindkeys and xdotool

You could also try to find a plugin for thunderbird that lets you add extra hotkeys and just bind Ctrl+' to close tab.

Last edited by Tes-- (2010-04-22 09:47:07)

Offline

Board footer

Powered by FluxBB