1

I have a Macbook which I want to map the right "command" key (also known as Super_R, RWIN) to AltGr. The reasons I want this is due to how a normal Norwegian keyboard has its square bracket keys and curly bracket keys mapped, among other things.

However, this is a problem.

I've mapped the key first with xmodmap, this works fine in most programs. But not in certain programs, in particular it fails to work in Firefox.

Relevant questions, but they don't help me:

https://superuser.com/questions/801611/how-to-make-all-applications-respect-my-modified-xkb-layout

https://wiki.archlinux.org/index.php/X_KeyBoard_extensio:

How to make AltGr+i,j,k,l work properly as cursor keys?

Xmodmap solution:

keycode 134 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift

Suspecting it was a problem with Xmodmap, I tried with XKB (X KeyBoard Extension): https://wiki.archlinux.org/index.php/X_KeyBoard_extension

key <RWIN> {         [ ISO_Level3_Shift ] };

However, the same problem persists.

By "problem" I mean that it simply doesn't work. Pressing e.g. my new AltGr+4 should produce a dollar sign, but it doesn't. It works fine in most programs (e.g. xterm), but not in Firefox. In Firefox it produces a "4" instead of a "$".

As the post at https://superuser.com/questions/801611/how-to-make-all-applications-respect-my-modified-xkb-layout explains:

"Some applications track keysyms like Control_L by themselves, others just look for the modifier bits in the state."

"Most probably, those programs that don't work, watch the modifiers and don't want to work when some are active."

I believe Firefox does the same.

My question is, how can I force an exact state to be sent to an application by the X server when I press a specific key combination?

This is what I have:

KeyPress event, serial 37, synthetic NO, window 0x4200001,
    root 0x2de, subw 0x0, time 1100024, (222,-357), root:(1005,749),
    state 0xc0, keycode 13 (keysym 0x24, dollar), same_screen YES,
    XLookupString gives 1 bytes: (24) "$"
    XmbLookupString gives 1 bytes: (24) "$"
    XFilterEvent returns: False

This is what I want (from a different laptop with a proper keyboard, ... is just that I didn't bother to type it by hand, as it is not relevant):

KeyPress event, serial 37, synthetic NO, window ...
   root 0x233, subw 0x0, time ...
   state 0x90, keycode 13 (keysym 0x24, dollar), same_screen YES,
   XLookupString gives 1 bytes: (24) "$"
   XmbLookupString gives 1 bytes: (24) "$"
   XFilterEvent returns: False

The relevant part, I believe, is the "state". The state specifies the modifier keys.

How can I force X to produce this state and keysym when I press Super_R + 4? If I can figure this out, I can probably map up the other keys that I need too, and finally have a keyboard I can use.

Your Answer

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

Browse other questions tagged or ask your own question.