3

EDIT: This question used to start with

I have a German keyboard layout where AltGr+Q, for example, results in @.

I have since changed keyboards and layouts, but the problematic behavior is similar.


I have a Russian keyboard layout where AltGr+8, for example, results in . This is desirable, since there is no other way to type this symbol in this layout. However, in applications such as Chrome AltGr+Left does not lead to going back one step in history, while the left Alt key (Alt+Left) works as intended.

Many solutions here show how to make AltGr behave as a regular Alt key, but this disables its third-level functionality. Is it possible to retain this third level functionality, but in situations, such as the one for Google Chrome have it behave as a regular Alt?

I'm running Ubuntu 18.04 with Gnome as the desktop manager.

Additional info:

$ /opt/google/chrome/chrome --version
Google Chrome 97.0.4692.71 unknown
$ apt-cache policy google-chrome-stable 
google-chrome-stable:
  Installed: 97.0.4692.71-1
  Candidate: 98.0.4758.80-1
  Version table:
     98.0.4758.80-1 500
        500 http://dl.google.com/linux/chrome/deb stable/main amd64 Packages
 *** 97.0.4692.71-1 100
        100 /var/lib/dpkg/status

Keyboard layouts chosen:

  1. English (United States) -> English (US) English (United States) -> English (US) Keyboard layout as shown by Ubuntu

  2. Russian -> Russian Russian -> Russian Keyboard layout as shown by Ubuntu

  3. Photo of actual keyboard

LLlAMnYP
  • 131
  • 1
    You can create custom shortcuts for Chrome. There are several shortcut extensions https://chrome.google.com/webstore/search/custom%20shortcuts – LarsAamo Jan 25 '21 at 07:50
  • might work. gnome shortcut key for AltGr+Q , to run a script which checks the current window is Crome using xdotool getwindowname=chrome , and then if so sendkeys for normal alt-left also using xdotool key down alt + left arrow. if not chrome then pass altgr+q as normal – pierrely Jan 26 '21 at 04:48
  • @pierrely that wouldn't fare so well, since I might need to type @ in a form in chrome. Like I did just now. – LLlAMnYP Jan 26 '21 at 09:21
  • then make another key combination to do your @'s? – pierrely Jan 26 '21 at 21:13
  • What exactly is your layout? This is dependent on the layout. For example, I have found one, German-Dead Acute, which can type AltGR+q=@ without disabling AltGr+Left/RightArrow=Back/Forward. – cipricus Feb 08 '22 at 09:59
  • The fact that this happens in Chrome (by the way, is it Chrome or Chromium? is it snap? what version?) is maybe the main problem here. (Chrome is the program that on Kubuntu does exactly what you ask: use AltGr as Alt when necessary.) But before finding why Chrome is different on your system I have to be sure that is the case: that's why I need the keyboard layout. to test. You should add in the question body all info involved, precise kb-layouts, not just how you add them; give image with list of active layouts. Are you interested in having a solution for Chrome of for all browsers? – cipricus Feb 12 '22 at 11:31
  • The layouts you use are capital. Add them clearly in the question body and describe exactly what's your problem and with which keyboard. (With both Russian and English?) – cipricus Feb 12 '22 at 11:33
  • Or, in order to clarify if this is a problem with your Chrome only or a layout problem, it may be simpler for you to test yourself a keyboard that I use (e.g. English-US-International with dead keys) and tell whether you have the same problem. – cipricus Feb 13 '22 at 09:10
  • @cipricus I've fixed up the question with some details. In the process I've noticed a striking mismatch between the keyboard layout visible through gnome's UI and what actually is on my keyboard. I suppose, this might be very much related. – LLlAMnYP Feb 14 '22 at 13:42
  • Why not buy a cheap ($10US) bluetooth keyboard. My desktop always has 2 keyboards attached. Tha second is in my bottom drawer and always paired/ connected. I use it to type from the sofa. You would think that they would share a context in the os (in fact I think I remember reading that this was the case) but they are at least partially independent, because I can activate Caps Lock on each w/ out affecting the other. – Nate T Feb 15 '22 at 09:15
  • First: this is getting very confusing: see my updated answer. The physical keyboard might be the problem. You might have been pressing a key believing it's ALTGR when its not. Secondly: I cannot identify your Russian keyboard, I see more than 10 in my list, from what you say it seems the basic default one but it is not I guess (testing that it doesn't do ALTGR+8 as said, that has no use of 3rd key), yours must be a different one. So, it its not too much effort for you, please test my layouts (see answer) and confirm you still have the problem. – cipricus Feb 15 '22 at 09:19
  • @NateT - How would that help? – cipricus Feb 15 '22 at 09:22
  • Your question title should be: Chrome AltGr shortcut stops working in Ubuntu Gnome version <?> with some layouts. I can guarantee that in most systems that doesn't happen and that you are entitled to a Gnome solution other than what I get for Firefox. (Or, it might be just a confusion related to your physical kb... and that should be clarified first, of course.) – cipricus Feb 15 '22 at 09:47
  • @ Cipricus ....?? Are we reading the same question? Im answering the title question... If you hook up a bt kb, configs will be seperate. That was the point I was trying to make. May only work w/ bluetooth??? IDK, Im going from exp. not knowledge... XD – Nate T Feb 15 '22 at 09:52
  • @NateT - then you should read the body too, and also my answer to get the context. the title is a bit too general, what is asked in fact it's something like: "Chrome AltGr+Arrows shortcuts to navigate history stop working in Gnome with some Layouts". – cipricus Feb 15 '22 at 09:56
  • You mean the comments? Gimme a few min. – Nate T Feb 15 '22 at 09:59
  • @NateT - You should test and confirm that with two keyboards you can have separate settings for ALTGR (one 3rd level, one not), which I doubt. But before that we have to consider the fact that Chrome should not behave like that (see my answer) and why it does it in Gnome but not Kubuntu. And even before that we should wait and see if the OP was not confused by the physical kb, different from the selected layout. – cipricus Feb 15 '22 at 10:03
  • @NateT - You mean the comments? I mean what the OP says in the question body: in applications such as Chrome AltGr+Left does not lead to going back one step in history, while the left Alt key (Alt+Left) works as intended. In my answer I look at various causes before trying a solution, especially considering that on my Kubuntu Chrome is not affected by this problem, while Firefox is (and thus I can test it). – cipricus Feb 15 '22 at 10:05
  • I agree regarding Chrome. As for testing, one-off comments are meant as suggestions. As in, if OP wants to try it out, now he/ she knows. I had never heard of an altGr key before reading this, so I doubt Ill be testing any time soon. Too many comments already. Have a good . Has anyone filed a bug report?* – Nate T Feb 15 '22 at 10:11

1 Answers1

1

SUMMING UP:

  • Test there is no confusion brought by the physical kb being different from the selected layout (see below); if no:

  • Fully identify your problematic layout (so that I can test) or test yourself one of my keyboards mentioned below and tell if affected by your problem; if they are affected, than it's a Chrome-on-Gnome problem, and we'll continue from there (fix Chrome? fix Gnome?)

  • Imagining we have no other solution, you have to chose between disabling ALTGR as 3rd level key (possibly enabling a different one) and changing to another kb layout not affected by the problem when navigating with Chrome.

Anyway, your question title in its initial form (How can I make AltGr behave as regular Alt in specific situations?) cannot receive a solution, it is far too general, it should be more like "Chrome AltGr-Arrows shortcuts not working in Gnome with some layouts".


UPDATE (read the rest only after having considered this):

Looking closely I see that your selected layout has AltGr where the physical one has CTRL, but also that the selected layout has another key for 3rd level, which on the physical is AltGr. How could that not be a problem? How does that work? When you say Altgr you are referring to what key? (the physical one on which is written CTRL or that on which is written ALTGR? are both acting as ALTGR?)

enter image description here

All this is getting very confusing and — if you expect an answer (and more effort from others) you should clarify basic things like this.

Only after clarifying the above continuing with the rest could make sense.

This answer should be considered a temporary one - with parts that would have fit a comment, but I find it easier for now (I'll edit accordingly) to post them here.


It seems that Chrome (unlike Firefox) should be able to detect whether a typing field (where special characters can be used) is selected or not. (Testing with different keyboard layouts, including two German ones —'German-Dead acute' and 'German(language)-English(layout)-International with AltGr dead keys'— I can confirm that AltGr in Chrome is reserved as a modifier for typing special characters like those you mention (and thus is not working with arrows) BUT ONLY when a typing field is selected, and that otherwise it can be used as normal Alt.)

What the browser does is reserve the third-level key, which by default is AltGr, when that key is required by the kb-layout. But that doesn't affect the default shortcut on my system: I haven't yet found a layout to replicate your problem.

We must first identify the problem: is it layout-specific, or is it (your) Chrome and/or system specific?

You have to check if indeed Chrome has that problem with all layouts that involve AltGr as 3rd level modifier or not. (For that you could try one of my layouts that qualify but that do not trigger the problem on my system: English US International with dead keys, French (French), Romanian standard. (That because I am still not able to get from you the exact layout that you use now!)

If with those layouts you still have the problem, then we will know for certain that your problem is either with your system or your Chrome version. (I don't think Chrome version is the problem.)


Anyway, for practical purposes yours is similar (even duplicate) to my Firefox question linked above, and the answer cannot be very different:

  • AltGr can become totally equal to Alt by selecting Right Alt key never chooses 3rd level under Key to choose 3rd level - example for KDE here, for Gnome here, and thus it is not reserved anymore, and the AltGr-Arrow (to navigate history) should work with any kb-layout.

  • In order to introduce a third-level key as an alternative to AltGr, after selecting Right Alt key never chooses 3rd level, you can select a new key to chose the 3rd level, and use that instead of AltGr to type special characters in the problematic kb-layout. (The problem with this solution is that the new 3rd level key loses its other uses as modifier (for example on this website Ctrl+L=hyperlink or Ctrl+K=code on selected text stop working with Right_Ctrl if that is selected as 3rd level selector, while Left_Ctrl works.) So, we should look for a less important key that could replace Altgr. I have selected CapsLock, and do uppercase with shift+key.)


The problem with this question is that it's still far too general. You say specific situations in general when in fact it's about AltGr-Arrow shortcut in Chrome. That should be the question: not about all situations, but about Chrome and specifically about the fact that default shortcuts stop working with 3rd level AltGr in Chrome, just like (in my case) in Firefox. In this sense yours looks like a duplicate of my question, except it's about Chrome and not Firefox. You may not like the answer under my question but if indeed Chrome is affected by the same problem you may have no other choice.

I cannot imagine a generic solution where the user would have a way to switch rapidly between the two different statuses of AltGr (as 3rd level modifier or not), other than the one in settings, and even then it would be very cumbersome. (What could that be? A shortcut to toggle the possibility of another shortcut?) That is not the problem. On all the systems that I have been able to test (Kubuntu 20.04 and 22.04, Linux Mint Xfce 20 and Windows 10) Google Chrome is keeping AltGr as 3rd level key without disabling the default shortcut to navigate history.

The mystery for me is still why Chrome acts differently on your system. In order to get close to that we have to rule out the layout as the culprit.

cipricus
  • 3,444
  • 2
  • 34
  • 85
  • 1
    only when a typing field is selected, and that otherwise it can be used as normal Alt. On my machine chrome does not do that. Gnome tweaks has similar settings for configuring the 3rd level modifier, but as it seems, either I'm stuck without the 3rd level key or it never behaves as normal. FWIW, I've long since changed my keyboard and am now using EN-US (intl) / Russian layouts. Perhaps, the behavior you have is specific to KDE? – LLlAMnYP Feb 09 '22 at 15:03
  • In Xfce too I can confirm that with a kb-layout that makes AltGr+Arrow to stop working completely in Firefox, Google Chrome still has that default shortcut for back-forward in history. The same in Windows. So, the problem must be with the kb-layout or (less probably) with Gnome (which, by the way, I've always avoided). Give me the exact details of your EN-US international and I will test more. In my experience there are many kb-layouts that don't require AltGr. – cipricus Feb 09 '22 at 15:27
  • I have edited to suggest (1) disabling AltGr as 3rd level selector and (2) selecting a new 3rd level selector. That might prove satisfying depending on your habits, priorities and design of physical keyboard. – cipricus Feb 09 '22 at 18:10
  • Upvote for all the effort. Give me the exact details of your EN-US international and I will test more. There's a great many places to start looking regarding keyboard layouts and configurations. Could you be more specific? Do you need some output of an xkb* command, a pastebin of some config file or something different altogether? – LLlAMnYP Feb 10 '22 at 13:40
  • @LLlAMnYP - I just mean the exact name of the layout so that I can finally see how it can be that Chrome behaves differently than on my system, which is odd. On my Kubuntu there is no layout called just English-US-International, there is one "with dead keys", another, "AltGr" etc see here. – cipricus Feb 10 '22 at 21:37
  • In gnome I go into Region & Language, hit the button to add a new layout and am presented with this: https://imgur.com/a/agXhf1j (all 4 relevant screenshots under this link) I then select English (United States) and then English (US) on the next dialog. For Russian I hit the ellipsis, type Russian in the search bar, select it, then select Russian again on the next screen. Sorry, explicitly stating "EN-US (intl.)" must have been a brainfart on my behalf. – LLlAMnYP Feb 12 '22 at 08:54
  • if you expect an answer (and more effort from others) you should clarify basic things like this. Please, have some patience. I understand that the OP may be confusing at face value and I do appreciate your effort, however the OP is over a year old and received some traction only now, when many of the original circumstances have changed. As for the mismatch between the layout and the physical keys, I imagine, enabling right alt as 3rd level modifier causes Ubuntu to remap some keys. I'll try to check that out and add details over the next 24hrs or so. – LLlAMnYP Feb 15 '22 at 11:53