LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Xmodmap mod keys (https://www.linuxquestions.org/questions/linux-software-2/xmodmap-mod-keys-794513/)

MTK358 03-10-2010 03:36 PM

Xmodmap mod keys
 
Is it possible to make a key print a different character while a certain other key is pressed using xmodmap?

MTK358 03-10-2010 07:27 PM

Anyone?

jlliagre 03-11-2010 10:36 AM

AFAIK, only when the other key is a modifier one (ie. shift, mode_switch or both) but I guess you already know that ...

By the way, bumping your own thread with your "Anyone" comment had an opposite effect than the one you were expecting. Zero replies threads are automatically bumped up several times but of course only if they still have no reply.

MTK358 03-11-2010 11:14 AM

Quote:

Originally Posted by jlliagre (Post 3894404)
AFAIK, only when the other key is a modifier one (ie. shift, mode_switch or both) but I guess you already know that ...

By the way, bumping your own thread with your "Anyone" comment had an opposite effect than the one you were expecting. Zero replies threads are automatically bumped up several times but of course only if they still have no reply.

What is the "mode_switch" key?

jlliagre 03-11-2010 04:03 PM

Usually the one with ALT-GR on it.

Code:

xmodmap -pm
will tell you more about these modifier keys.

MTK358 03-11-2010 04:59 PM

My keyboard does not have an Alt Gr key on it.

Code:

$ xmodmap -pm
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift      Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control    Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3     
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)


jlliagre 03-11-2010 05:15 PM

That's mod5 anyway.

MTK358 03-11-2010 07:02 PM

What does mod5 do?

I really with there was some good xmodmap reference somewhere but I just can't find one.

jlliagre 03-11-2010 07:17 PM

Mod5 is modifying what a key will send, just like shift + 'a' will make 'A' instead of a lowercase 'a'.

Have a look at the Mappings paragraph here:

http://en.wikipedia.org/wiki/X_Windo..._core_protocol

MTK358 03-11-2010 08:04 PM

Good, but it still didn't help me understand what Mode_Switch and mod1-5 do.

jlliagre 03-11-2010 08:38 PM

Hmm, I just tried out something that used to work to give you an example but it no more does :-(
Looks like the X server and its clients have quite evolved since last time I checked ...

DavidMcCann 03-12-2010 12:08 PM

I always get confused with Xmodmap and the man page is not much use (which is why I prefer to rewrite the driver files), but I think

Lock = caps lock
Mod1 = alt (aka meta)
Mod2 = number lock
Mod4 = super (aka windows)
Mod5 = level 3 shift (aka AltGr, Opt)

Mod3 I can't remember :confused:

The double naming can be confusing at first. "Caps_Lock" is the name of the key, as established by the keyboard driver, while "Lock" is the function it carries out.

If you have a pc keyboard without AltGr, you must be in the USA: everywhere else, it's where you have your right Alt key. The desktop configuration system will enable that to be changed, and the Level 3 Shift can go on RAlt, LAlt, RWin, LWin, Menu, LWin+RWin, etc, etc. I have it where the CapsLock used to be :)

MTK358 03-12-2010 12:25 PM

Quote:

Originally Posted by DavidMcCann (Post 3895990)
I always get confused with Xmodmap and the man page is not much use (which is why I prefer to rewrite the driver files), but I think

What driver files? If it's easier than Xmodmap I want it!

Quote:

Lock = caps lock
Mod1 = alt (aka meta)
Mod2 = number lock
Mod4 = super (aka windows)
Mod5 = level 3 shift (aka AltGr, Opt)
I'm so confused. What does mod1-5 mean? Do you manually map them to keyboard keys, or are they auto-magically associate with certain keys or what?

Quote:

If you have a pc keyboard without AltGr, you must be in the USA: everywhere else, it's where you have your right Alt key.
Yes, I'm in the USA. I have never actually seen a keyboard with an AltGr key except in pictures online.

DavidMcCann 03-14-2010 06:15 PM

It's a bit difficult to advise you, because I'm not sure exactly what you are trying to do, or what facilities exist in your distro, and I've largely forgotten xmodmap. But here goes.

Using xmodmap, you can write a shell script which is run at log-in to reconfigure keys. At present Alt_R is linked to Mod1, so you have to clear that setting, and then re-link it to Mod5 to give an ISO type keyboard with AltGr key. Then you can assign the scan code for an alphanumeric key (found with xev) to its usual value and extras values for AltGr and AltGr+Shift. Look at the man page, and I think there's an explanation in this site's wiki.

If you have a reasonable desktop or window manager, you should be able to set a third level shift using the keyboard configuration.

Your keyboard is described by /usr/share/X11/xkb/symbols/us

You can add an entry to create AltGr
key <RALT> { [ ISO_Level3_Shift ] };

and add up to two extra symbols to any key as I have done in
key <AC02> {[ s, S, Greek_sigma, Greek_SIGMA ]};

MTK358 03-14-2010 07:16 PM

My goal would be for a key to be able to act as a modifier and a typing key at the same time. For example typing 'b' while holding down 'a' would type an unrelated character, but pressing and releasing 'a' would type an 'a'.

And I do not have any kind of DE or GUI that controls key mappings, and it is not necessary for this to be done using Xmodmap.


All times are GMT -5. The time now is 11:38 PM.